--Using Regular expressions in a practical life --
Hey Guys, Today i was writing a post & come with a particular problem. The problem was , I was writing 108 names of God Surya. I wrote them one by one in every new line in notepad. Later I thought I forgot to add OM as a prefix to each name. Now what to do? I can not type each name & add one by one.
So for that I thought to use techniques of regular expression & add them in intelligent way. So what I did was, I opened that file into Notepad++ .
Then pressed Ctrl+H to open find & replace box . At the search mode, i selected the option "Regular Expression" .
Now at "Find what" box - I typed "^" ==>This indicates beginning of each line
and at "Replace with box" - I typed "OM ". Finally I clicked on Replace all.
That's it. In one shot, i did my whole changes. Wow it was fantastic.
Similarly, if you have text like
word1
word2
word3
and you wanted to make some thing like -
test: "word1"
test: "word2"
test: "word3"
All you need to do is
Search = ^([a-Za-z0-9]+)$
Replace= test:"\1"
This is just a very simple example of using regular expression in notepad++. You can do much better things related to matching & replacing various types of patterns by using regular expressions.
Happy Learning.. ..!!
Hey Guys, Today i was writing a post & come with a particular problem. The problem was , I was writing 108 names of God Surya. I wrote them one by one in every new line in notepad. Later I thought I forgot to add OM as a prefix to each name. Now what to do? I can not type each name & add one by one.
So for that I thought to use techniques of regular expression & add them in intelligent way. So what I did was, I opened that file into Notepad++ .
Then pressed Ctrl+H to open find & replace box . At the search mode, i selected the option "Regular Expression" .
Now at "Find what" box - I typed "^" ==>This indicates beginning of each line
and at "Replace with box" - I typed "OM ". Finally I clicked on Replace all.
That's it. In one shot, i did my whole changes. Wow it was fantastic.
Similarly, if you have text like
word1
word2
word3
and you wanted to make some thing like -
test: "word1"
test: "word2"
test: "word3"
All you need to do is
Search = ^([a-Za-z0-9]+)$
Replace= test:"\1"
This is just a very simple example of using regular expression in notepad++. You can do much better things related to matching & replacing various types of patterns by using regular expressions.
Happy Learning.. ..!!
No comments:
Post a Comment