2

I recently learned a little Python and I couldnt find a good list of the RegEx's (don't know if that is the correct plural tense...) with complete explanations even a rookie will understand :)

Anybody know a such list?

Peter Boughton
  • 102,341
  • 30
  • 116
  • 172
Latze
  • 1,735
  • 7
  • 21
  • 29
  • 1
    This seems to be the [standard answer](http://stackoverflow.com/questions/4736/learning-regular-expressions). Very good site. – anton.burger Jul 16 '10 at 16:18
  • 1
    "couldnt find a good list of the RegEx's"? Did you look at the Python documentation? Where **did** you look? – S.Lott Jul 16 '10 at 17:46
  • Latze, you do not need to put `[closed]` on the end of the title for a solved question. SO knows that you have accepted a solution (and highlights such questions differently), and - more to the point - a 'closed' question is something else. – Peter Boughton Jul 18 '10 at 22:58

5 Answers5

12

Vide: regEx

     

Glorfindel
  • 19,729
  • 13
  • 67
  • 91
Jet
  • 1,163
  • 9
  • 7
5

Well, for starters - hit up the python docs on the re module. Good list of features and methods, as well as info about special regex characters such as \w. There's also a chapter in Dive into Python about regular expressions that uses the aforementioned module.

Mr.Wizard
  • 23,689
  • 5
  • 41
  • 116
Ben Hayden
  • 1,271
  • 9
  • 15
1

Check out the re module docs for some basic RegEx syntax.

For more, read Introduction To RegEx, or other of the many guides online. (or books!)

You could also try RegEx Buddy, which helps you learn regular expressions by telling you what they do an parsing them.

John Howard
  • 50,339
  • 21
  • 44
  • 63
1

The Django Book http://www.djangobook.com/en/2.0/chapter03/ chapter on urls/views has a great "newbie" friendly table explaining the gist of regexes. combine that with the info on the python.docs http://docs.python.org/library/re.html and you'll master RegEx in no time.

an excerpt:

Regular Expressions

Regular expressions (or regexes) are a compact way of specifying patterns in text. While Django URLconfs allow arbitrary regexes for powerful URL matching, you’ll probably only use a few regex symbols in practice. Here’s a selection of common symbols:

Symbol Matches
. (dot) Any single character
\d Any single digit
[A-Z] Any character between A and Z (uppercase)
[a-z] Any character between a and z (lowercase)
[A-Za-z] Any character between a and z (case-insensitive)
+ One or more of the previous expression (e.g., \d+ matches one or more digits)
? Zero or one of the previous expression (e.g., \d? matches zero or one digits)
* Zero or more of the previous expression (e.g., \d* matches zero, one or more than one >digit)
{1,3} Between one and three (inclusive) of the previous expression (e.g., \d{1,3} matches >one, two or three digits)

EroSan
  • 249
  • 5
  • 13
0

But it's turtles all the way down!

Community
  • 1
  • 1
Greg Bacon
  • 121,231
  • 29
  • 179
  • 236