Regular Expressions
Regular Expression
1. Using Regular Expression for matching Email
^\w+@\w+\.\w{3}$
ashish@abc.com
^\w+@[\w.]+\.\w{2,3}$
ashish@abc.co.in
^[\w%.+\-]+@[\w.\-]+\.[A-Za-z]{2,3}$
ashish@abc.co.in
ashish@abc.co.uk
ashsih@abc.com
2. Using Regular Expression for matching URL
^http(s?):\/\/[\w.\-]+\.[\w]+.*$
tps://asbjb.com
http://12.22.11.111
https://bdbndbd.ccbcb.skns/pwwknw/?sss.html
http://vulcan-olpite.unicommerce.info:8080/fleet/riders?offset=0&limit=10&keyword=&sort_direction=1&sort_by=code
https://www.blogger.com/blogger.g?blogID=6445636638945131440#editor/target=post;postID=1834207132756697935
3. Using Regular Expression for matching Decimal
^\d*\.\d+|\d+$
.12
0.12
12
2.13
4. Using Regular Expression for matching Time
^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?(( EST)|( GMT -5)|(AM|PM|am|pm))?$
2:35
2:35PM
2:35pm
02:35
14:25
14:24:23
12:23 EST
12:34 GMT -5
24:23
^([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?(( EST)|( GMT -5)|(AM|PM|am|pm))?$
2:35
2:35PM
2:35pm
02:35
14:25
14:24:23
12:23 EST
12:34 GMT -5
24:23
Comments
Post a Comment