Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between \d+ and \d- OR \w+ and \w- in regular expression terms?

Tags:

python

regex

As per title, what is the difference between:

\d+ and \d- \w+ and \w-

in regular expression terms? What influence has + and - ?

like image 662
Bogdan Goie Avatar asked Dec 04 '13 12:12

Bogdan Goie


1 Answers

\d+ means one or more digit [0-9] (depending on LOCALE)
\d- means a digit followed by a dash -

\w+ means one or more word character [a-zA-Z0-9_] (depending on LOCALE)
\w- means a word char followed by a dash -

like image 85
Toto Avatar answered Sep 22 '22 13:09

Toto