sed-4.1.5: \w and \W don't function as escapes inside [ ]
Provides native Win32 open source ports and utilities
Brought to you by:
gnuwin32
Bug: \w (word character) and \W (nonword character) don't function as escapes inside character classes. Inside character classes, sed treats \w as literal \' followed by literal
w'. Likewise for \W
Example: echo file~1.txt|sed -r s/[\w~.]+/foo/' returns
filefoo1.txt', not `foo' as expected
Workaround: Inside character classes, replace \w with A-Za-z0-9_ ; e.g. echo file~1.txt|sed -r s/[A-Za-z0-9_~.]+/foo/' returns
foo'
If you don't plan to fix this bug, can we at least document it in sed.html, sed.pdf, etc? I can volunteer to do that. Please let me know if you want me to.
Friendly Greetings,
Lawrence Mayer
Logged In: YES
user_id=217802
Originator: NO
As far as I know, inside bracket expressions, the backslash loses it special meaning; see the POSIX standard http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap09.html#tag_09_03_05
So this does not seem to be a bug.