When running the following sed command under Windows (to uppercase a keyword which isn't part of another word):

"c:\Program Files (x86)\GnuWin32\bin\sed.exe" -e "s/[^a-z]*declare[^a-z]*/DECLARE/I" "SqlFile.sql"

will turn declare @returntable from SqlFile.Sql into DECLAREreturntable.

But adding capturing groups to transport the surrounding characters to the destination string, will leave declare lowercased:

"c:\Program Files (x86)\GnuWin32\bin\sed.exe" -e "s/([^a-z]*)declare([^a-z]*)/\\1DECLARE\\2/I" "SqlFile.sql"

Why does sed apply different rules to grouped sets in comparison to ungrouped ones?

(I know that the \b word boundaries are a better way to uppercase keywords, but I observed this sed behaviour and was wondering what the reason was)

link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.