A few regular expression examples

A few regular expression examples

Hey there,
Here you can find some examples using regular expression if you want to test your own regular expression you could use the following website to do it:

http://rubular.com/

Regular expresion if you want for example match a exact word and that word is inside a full sentence sometimes and sometimes the first word or sometimes is the last word in the sentence you could use the following expression to get the correct matches:

( |^)404( |$)
or
(^|\s)404(\s|$)

The above regular expression will match with the following sentences:
404


$404
0

404
 404


hola 404 excellent

404 page

page 404
 404

$404 hello

Using a regular expression for select one word between many words
then some text and then an additional matcher text you could use the
following regular expression:

(product|item|page)(.)* is no longer available

Using different regular expression with many matchers and apply only
one of them you need to use the character ‘|’ for example:

/this match|other matcher|third matcher/
No Comments

Post A Comment