Regex for French telephone numbers

You can use: ^ (?:(?:\+|00)33|0) # Dialing code \s*[1-9] # First number (from 1 to 9) (?:[\s.-]*\d{2}){4} # End of the phone number $ See demo It allows whitespaces or . or – as a separator, or no separator at all

haskell regex substitution

I don’t think “just roll your own” is a reasonable answer to people trying to get actual work done, in an area where every other modern language has a trivial way to do this. Including Scheme. So here’s some actual resources; my code is from a project where I was trying to replace “qql foo … Read more

Git add lines to index by grep/regex

patchutils has a command grepdiff that can be use to achieve this. # check that the regex search correctly matches the changes you want. git diff -U0 | grepdiff ‘regex search’ –output-matching=hunk # then apply the changes to the index git diff -U0 | grepdiff ‘regex search’ –output-matching=hunk | git apply –cached –unidiff-zero I use … Read more

What is (\d+)/(\d+) in regex?

Expanding on minitech’s answer: ( start a capture group \d a shorthand character class, which matches all numbers; it is the same as [0-9] + one or more of the expression ) end a capture group / a literal forward slash Here is an example: >>> import re >>> exp = re.compile(‘(\d+)/(\d+)’) >>> foo = … Read more

tech