Python Forum
What package to install to PyCharm... REGEX or RE?
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.
Reply
#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']
Reply
#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?
Reply
#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'
Reply
#5
Understood... Thanks doc!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem install somewhere package akbarza 1 475 Dec-27-2023, 01:25 PM
Last Post: Gribouillis
  Not able to install package caldwellpy and requirement txt file Samta282006 1 700 Dec-07-2023, 11:59 PM
Last Post: Larz60+
  Cannot install tensorflow, numpy etc in Pycharm with Python 3.10 plumberpy 2 3,417 Oct-07-2021, 05:33 AM
Last Post: plumberpy
  Problem: Restart kernel onPydev console when trying to install a python package poppy2020 1 7,667 Nov-25-2020, 06:13 PM
Last Post: Larz60+
  invalid syntax when trying install package Omer_ 1 2,363 Jul-28-2020, 03:51 PM
Last Post: buran
  Can't install Numpy in Pycharm asdasdasd 4 4,714 Jun-26-2020, 05:17 PM
Last Post: asdasdasd
  REGEX Install Error in PyCharm charlesauspicks 1 2,759 May-14-2020, 08:10 PM
Last Post: buran
  Error in importing package in pycharm fullstop 0 2,336 Dec-12-2019, 04:03 PM
Last Post: fullstop
  install pacman package without password DKRoots 2 2,049 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 3,757 Jul-19-2019, 04:58 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020