grep sed or awk me some values
January 10, 2007 2:36 PM
Subscribe
I want grep (or sed or awk) to return a word between two "bookend" words.
Here are two examples of strings that I want to grep, with the word I want returned in bold in each case:
DBConnector dbConn = new DBConnector();
DBConnector aDBConnector=new DBConnector();
So the expected output from the grep would be:
dbConn
aDBConnector
There can be empty space before or after the strings used in the examples, but the string itself will usually only span one line.
It might also be useful if the regexp just gets the next word after DBConnector since it is entirely possible the code might look like this:
DBConnector dbConn;
dbConn = new DBConnector();
Cheers!
Yes, we're having connection problems.
posted by Null Pointer and the Exceptions to computers & internet (14 comments total)
posted by aberrant at 2:42 PM on January 10, 2007