a regex expression

Vu Pham vu at sivell.com
Fri Nov 5 08:45:43 PDT 2010


  I get several strings in the format "bla bla bla # something here 
78900". I want to get rid of anything inclusively from # to the last 
space before the last 5 digits, so that

bla bla bla # something here 78900    => bla bla bla 78900
bla bla bla # 12345 something 77024 here 98765    => bla bla bla 98765

The regex "\#.* [0-9]{5}$" gives me the condition I want but it also 
removes the last 5 digits I want to retain.

In other words, I would like to look for a "replace" regex that removes 
anything from the first # to the end but the last 5 characters.

Any advice is greatly appreciated.

Vu



More information about the Linux-users mailing list