Regular Expression, an introduction with full of examples
Let’s search txt files in a folder. If you are in widows OS then you will open search and will type ‘*.txt’. If you are using unix then you’ll use ‘ls *.txt’.
‘*’ is commonly used regular expression’s element. Sometimes we called it as wild character.

Take another simplest example.
Amty*.txt
What does above pattern do? It’ll search for all files which are starting with ‘Amty’ and ending with ‘.txt’.
Regular expression is nothing but the combination of such elements along with simple text. Programmers or Mathematics student can understand an element as variable. Now see
127x+43y=z
-78x-34y=125z
Above expressions can be written as ‘Ax+By=C’. Here you can put various value of A,B,C to get above result.
Now consider a situation where you have to extract above expression from a page full with some text. For example
Artcle-stack.com is a 127x+43y=z online sharing and learning site. -78x-34y=125z Users registrations is must to see restricted contents and articles Subscription is required for email alerts.
You have to extract all the expressions look like ‘Ax+By=C’. Where given pattern is surrounded by space. So a possible RE would be
RE
[\-0-9]*x[\+\-]{1}[0-9]*y=[^ ]*
Result
[0] => 127x+43y=z
[1] => -78x-34y=125z
Above RE would not clear to you until you read about elements of Regular expression. So keep reading.
