Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 What package to install to PyCharm... REGEX or RE?
#1
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.
Quote
#2
(May-23-2020, 12:16 PM)charlesauspicks Wrote: Do they mean the same thing please?
re is in the Python Standard Library
regex is a 3-party module,that why is on PyPi.
regex Wrote:This regex implementation is backwards-compatible with the standard re module,
but offers additional functionality.
So 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']
Quote
#3
(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?
Quote
#4
(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'
Quote
#5
Understood... Thanks doc!
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  REGEX Install Error in PyCharm charlesauspicks 1 202 May-14-2020, 08:10 PM
Last Post: buran
  Error in importing package in pycharm fullstop 0 225 Dec-12-2019, 04:03 PM
Last Post: fullstop
  install pacman package without password DKRoots 2 301 Sep-22-2019, 07:53 PM
Last Post: DKRoots
  Can't decide - install modules with Ubuntu package manager (apt) or pip3 in venv Thisisaline 6 656 Jul-19-2019, 04:58 PM
Last Post: snippsat
  can't install package web in version python 3.7 a21250450 1 583 Mar-29-2019, 11:28 AM
Last Post: Larz60+
  PyDev package install/download at runtime user2103 0 1,038 Jan-30-2018, 08:39 AM
Last Post: user2103
  Problems installing Python - Failed to install MSI package Johnnyq70 1 2,131 Oct-29-2017, 08:50 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)