Regular expression - skip string in quotes using sed

Posted by milano on Stack Overflow See other posts from Stack Overflow or by milano
Published on 2011-03-15T23:24:14Z Indexed on 2011/03/16 0:09 UTC
Read the original article Hit count: 134

Filed under:
|

I have string like this:

"Some standard text CONST_INSIDE_QUOTES" blah blah CONST "There might be another quotes"

The thing is, that i want to replace all constants in string with some text, but it mustn't be applied on constants inside text in quotes. I have this regex:

sed "s/([A-Z][A-Z0-9_]*)([^a-z])/<span class=\"const\">\1<\/span>\2/g"

which of course works for all consts. Any ideas how to exclude its apply on quotes constants? Unfortunately sed only...

© Stack Overflow or respective owner

Related posts about regex

Related posts about sed