Pages

some commonly used regular expression every one should know

1. Regular Expression for matching Email
^([a-z0-9_-\.]+)@([a-z0-9-_\.]+)\.([a-z\.]{2,6})$

2. Regular Expression matching User Name

^[a-z0-9-_]{3,16}$

3. Regular Expression for matching URL

^(https?:\ /\ /)([\da-z\._/]+)\??[a-zA-z-0-9\._=&/]*$




4. Regular Expression matching IPv4

^([0-1][0-9]?[0-9]?|2[0-5]?[0-4]?|([3-9])[0-9]?)\.([0-1][0-9]?[0-9]?|2[0-5]?[0-5]?|([3-9])[0-9]?)\.([0-1][0-9]?[0-9]?|2[0-5]?[0-5]?|([3-9])[0-9]?)\.([0-1][0-9]?[0-9]?|2[0-5]?[0-5]?|([3-9])[0-9]?)$

                                     or

^([0-1][0-9]?[0-9]?|2[0-5]?[0-4]?|([3-9])[0-9]?)\.(([0-1][0-9]?[0-9]?|2[0-5]?[0-5]?|([3-9])[0-9]?)\.){2}([0-1][0-9]?[0-9]?|2[0-5]?[0-5]?|([3-9])[0-9]?)$