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
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
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
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
See uniq -c. You’ll want to pull out the bit you want, sort the result, pipe thru uniq, sort the output. Something like this maybe: egrep ‘\.[0-9]+:’ output.txt | sort | uniq -c | sort -nr Clarification: I’ve used grep here because it’s not clear what your output.txt format looks like, but you’ll want to … Read more
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
Neither standard nor extended regular expressions support the look behind. Use Perl compatible regexes: grep -P ‘(?<!\\)xxx’ test.tex
This is because you are using the hyphen within other characters, so that grep understands it as a range, which happens to be invalid. You are basically doing grep “[\-‘]” file This is interpreted by grep as you providing a range of characters to be checked on, like for example grep “[a-z]” file. But the … Read more
You can search for all non-digits using: \D+ OR [^0-9]+ And replace by empty string. RegEx Demo
If you are wanting to do a pattern match on numbers, the way to do it in mongo is use the $where expression and pass in a pattern match. > db.test.find({ $where: “/^123.*/.test(this.example)” }) { “_id” : ObjectId(“4bfc3187fec861325f34b132”), “example” : 1234 }