Hi,
I am not that good with reg exp and sed. But I was just looking at something the other day and came across a situation.
When I ran the below command:
echo "123 word" | sed 's/[0-9]*/(&)/'
the op was:
(123) word
But when I ran:
echo "123 word" | sed 's/[0-9]*/(&)/g'
the o/p was:
(123) ()w()o()r()d()
And when I ran
echo "123 word" | sed 's/[0-9]+/(&)/g'
or
echo "123 word" | sed 's/[0-9]+/(&)/'
nothing happened !!!
Can someone please help me out with an explanation?
Thanks in advance
sed uses a regex engine. Henry Spencer wrote one of the first complete ones. Since then implementations of sed have changed the regex over time. gsed is an example. This makes giving you an answer hard unless we know: