A regular expression is a system used in programming for pattern matching.
It could be used to text search and replacing.
/./ Matche each and every single character
/\d+/ Matche any kind of digit one or more
/\w/ Matche anything a-z, 0-9, _
/\s/ Matche every space
/[a-z]+[3-9]+/ Character Set for matching
example:
coal547
goal254
Boal
Poal
/(\.in)?/ Basically it's for optional. Question mark to check whether
it is or not of the preceding token
Look Around:
------------
? mark is not going to include in the result
= sign is going to match
! sign is not going to match
example: Lookbehind
price is $500
price is €600
(?<![$])(?<=€)\d+
(?<=€) Positive Lookbehind
(?<![$]) Negative Lookbehind
example: Lookahead
sharthak.com
harpikpandy.ru
[a-z]+(?=\.com)
(?=\.com) Positive Lookahead
[a-z]{11}(?!\.com)
(?!\.com) Negative Lookahead
Anchors:
--------
/com$/ $ match at last of the line
/^com/ ^ match at starting point of the line
/com\b/ b/ boundary of the line. it's serach for starting and the end
example:
google.com
com.googula.name
Like this:
Like Loading...
Related