Wednesday, November 16, 2016

Python : regular expression

https://regex101.com

^[1-9]\d*[G]$

^ asserts position at start of the string
Match a single character present in the list below
[1-9]
1-9 a single character in the range between 1(ASCII 49) and 9 (ASCII 57) (case sensitive)

\d*
 matches a digit (equal to [0-9])
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[G]
G matches the character G literally (case sensitive)
$ asserts position at the end of the string

a{3}
Matches exactly 3 consecutive `a` characters

^(?!root|0).*$
cannot start with root or 0


No comments:

Post a Comment