![]()
The simplest way to use regular expressions is when we search for a single word.
For this article , we’ll use the command line tool called ‘egrep’ (egrep is available for many systems, like DOS, Windows, MacOS and Unix)
So let’s say that we have a file called article1.txt like this :
We want to search for the word ‘ERP’.
We’ll use the following syntax : egrep 'ERP' article1.txt (screen2)
As you can see , egrep returns all the lines that contain the word we are looking for.
That was a simple first example.
Now let’s say that we want to search another file that contains one word at every line for the word ‘cat’.
First we type more wordlist.txt at the command prompt to see what are the contents of this file :
Now if we use the same syntax, that we used in our first example, to search for the word cat egrep 'cat' wordlist.txt, the system returns two lines :
So how do we get only the lines that contain the word cat?
The answer here is to use metacharacters : ^(caret) and $(dollar)
The purpose of ^ and $ is to match the beginning and the end of the line respectively.
So let’s try this syntax now egrep '^cat$' wordlist.txtto see how it works :
That’s it!Now we can get only the lines that contain the exact word(s) we are looking for!
Stay tuned for more exciting regular expressions!






Great resource! Thanks for creating it. Keep working that way.
nice to be here blog.devcanvas.org admin found your website via search engine but it was hard to find and I see you could have more visitors because there are not so many comments yet. I have discovered website which offer to dramatically increase traffic to your site http://xrumerservice.org they claim they managed to get close to 1000 visitors/day using their services you could also get lot more targeted traffic from search engines as you have now. I used their services and got significantly more visitors to my website. Hope this helps
They offer best backlinks Take care. Jason
Hey. Very nice blog!! Guy .. Beautiful .. Wonderful .. I will bookmark your website and take the feeds additionally…I am glad to locate a lot of helpful information here within the post. Thanks for sharing..