|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionGuys , we all know that regular expressions are very useful for checking any kind of patterns. BackgroundSo we have to know how to write regular expressions for our patterns. But don't worry here i will provide some but very useful regular expressions which will be useful for our coding.Using the codejust copy and paste Regular Expression from here to your code.// // this are the regular expressions for all purposes... //For checking opening and closing tab of specific HTML tags.. "regex"><TAG\b[^>]*>(.*?)</TAG> //for any HTML tags starting and ending.. "regex"><([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1> //For deleting white spaces from text... "regex">^[ \t]+|[ \t]+$ //For Checking IP address between 0..255... "regex">\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\."regex">(25[0-5]|2[0-4][0-9]|[01]?[0-9] "regex">[0-9]?)\."regex">(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\."regex"> "regex">(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"regex">"regex">"regex"> //For floating point numbers with sign... "regex">[-+]?[0-9]*\.?[0-9]+ //for floating point numbers with exponents... "regex">[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?"regex"> //For email validation... "regex">^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$ "regex">"regex">"regex">"regex">"regex">"regex">//or you can try for .Museum and etc.. "regex">"regex">"regex">"regex">"regex">"regex">^[A-Z0-9._%-]+@[A-Z0-9.-]+\.(?:[A-Z]{2}|com|org|net|biz|info|name|aero|biz|info|jobs|museum|name)$ "regex">"regex">"regex">"regex">"regex">"regex"> //Date format for yyyy-mm-dd betwwen 1900-01-01 and 2099-12-31 "regex">(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01]) "regex">//Date format for mm/dd/yyyy betwwen 1900-01-01 and 2099-12-31 "regex">(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d"regex"> "regex"> //Date format for dd-mm-yyyy betwwen 1900-01-01 and 2099-12-31 "regex">(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d //finding word in a string.. "regex">^.*\b(one|two|three)\b.*$ //one,two,three may be your words... //for deleting duplicate lines from text file... "regex">^(.*)(\r?\n\1)+$ //For checking digits.. ^[0-9] //for checking alphabets... ^[a-z] "regex">//REgular Expression for some Credit cards validations... "regex"> //"Visa" ^[4]([0-9]{15}$|[0-9]{12}$) //"MasterCard" ^[5][1-5][0-9]{14}$ //"Discover" ^6011-?\\d{4}-?\\d{4}-?\\d{4}$ //"Diners Club" (^30[0-5][0-9]{11}$)|(^(36|38)[0-9]{12}$) //"American Express" ^[34|37][0-9]{14}$ "regex"> //"enRoute" ^(2014|2149)[0-9]{11}$ //"JCB" ^3[0-9]{15}$)|(^(2131|1800)[0-9]{11}$) Points of InterestI like to Share my knowledge with you, because i am also one of you, taht if i don't know anything then i come to you...so keep excahnge of knowledge... History
|
||||||||||||||||||||||