Showing posts with label Regular expressions. Show all posts
Showing posts with label Regular expressions. Show all posts

Thursday, February 9, 2012

Microsoft Excel forumula for text

I had a requirement where I was having an excel sheet and based on one column's data (which is a text), I had to populate another column to provide analysis.

Basically, I wanted to find keyword prjtmp and if it is found in given cell, I want to put "DONT WORRY" in the result column. Below was the formula I put in the desired cell and BOOM!!! It worked!!! :)


=IF(ISNUMBER(SEARCH("*prjtmp*",C2)),"DONT WORRY","")

Friday, November 6, 2009

How to grep next word after a match?

This example of regex will search for a given word and then pick the next word also as output

# echo "This example will pick next word as well" | /usr/sfw/bin/ggrep -o -E -- "next \w+"
next word


Note: This example is good for Solaris system. For any other system, may be a GNU grep will produce same output!!!

How to delete the last character in a line?

This is simple and without any description, here is the regex.


# echo "This is last character" | sed 's/.$//g'
This is last characte