What package to install to PyCharm... REGEX or RE? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: What package to install to PyCharm... REGEX or RE? (/thread-27032.html) |
What package to install to PyCharm... REGEX or RE? - charlesauspicks - May-23-2020 Hello, I am still very new to Python, and I want to write a Python program using Regular Expressions. Now, I am a bit confused as to what Python package to install in PyCharm. Since Python has a built-in package called re, which can be used to work with Regular Expressions, do I still need to install the REGEX package from PyPi.org? Then, if I do need the REGEX package, what should I import before proceeding?: import re or import regex? Do they mean the same thing please? Please help me out. Thanks in anticipation. RE: What package to install to PyCharm... REGEX or RE? - snippsat - May-23-2020 (May-23-2020, 12:16 PM)charlesauspicks Wrote: Do they mean the same thing please? re is in the Python Standard Libraryregex is a 3-party module,that why is on PyPi. regex Wrote:This regex implementation is backwards-compatible with the standardSo it offers additional functionality,but just using re work for most use cases.>>> import re >>> >>> s = 'cat and dog' >>> re.findall(r'dog', s) ['dog'] >>> re.findall(r'dog|cat', s) ['cat', 'dog'] RE: What package to install to PyCharm... REGEX or RE? - charlesauspicks - May-23-2020 (May-23-2020, 12:30 PM)snippsat Wrote: import re So, that means importing the re module after installing REGEX from PyPi will give me access to the functions in the REGEX package, is that correct? Or I still need to import regex separately before I can use the functions contained therein? RE: What package to install to PyCharm... REGEX or RE? - snippsat - May-23-2020 (May-23-2020, 12:48 PM)charlesauspicks Wrote: Or I still need to import regex separately before I can use the functions contained therein?Have import regex to use it's additional functionality.So it work the same as example over,but has add on stuff like eg expandf .>>> import regex >>> >>> s = 'cat and dog' >>> regex.findall(r'dog', s) ['dog'] >>> regex.findall(r'dog|cat', s) ['cat', 'dog'] >>> >>> # Using add on <expandf> >>> m = regex.match(r"(\w)+", s) >>> m.expandf("{0} {1}") 'cat t' RE: What package to install to PyCharm... REGEX or RE? - charlesauspicks - May-23-2020 Understood... Thanks doc! |