William Roeder
2014-05-25 14:17:24 UTC
Html/pdf docs () for 1) for postfix operators, like \(abcd\)* and 2)
back references. The problem is when using *both*.
echo 12345ab|sed -r "s/^([^a]{3})*(a)/<\1><\2>/"
12345ab
does not match as expected
echo 123456ab|sed -r "s/^([^a]{3})*(a)/<\1><\2>/"
<456><a>b
expected <123456><a>b
adding a second grouping is a work around
echo 123456ab|sed -r "s/^(([^a]{3})*)(a)/<\1><\3>/"
<123456><a>b
C:\Users\Bill>sed --version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-gnu-***@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
The ***@gnu.org address is in the pdf chapter 7 so I cc'ed there.
back references. The problem is when using *both*.
echo 12345ab|sed -r "s/^([^a]{3})*(a)/<\1><\2>/"
12345ab
does not match as expected
echo 123456ab|sed -r "s/^([^a]{3})*(a)/<\1><\2>/"
<456><a>b
expected <123456><a>b
adding a second grouping is a work around
echo 123456ab|sed -r "s/^(([^a]{3})*)(a)/<\1><\3>/"
<123456><a>b
echo 123456a123ab|sed -r "s/(([^a]{3})*)(a)/<\1><\3>/g"
<123456><a><123><a>bC:\Users\Bill>sed --version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-gnu-***@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
The ***@gnu.org address is in the pdf chapter 7 so I cc'ed there.