We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
'Sed' command #5
'Sed' command #5
Sort by
recency
|
90 Discussions
|
Please Login in order to post a comment
As simple as that.
sed -E 's/(\d{4}) (\d{4}) (\d{4}) (\d{4})/\4 \3 \2 \1/g'
pretty hardcoded but still works
Test case 3 does NOT confirm to the problem specification:
This works
as far as I know the 'sed ' only supports BRE and ERE, and neither of them support perl character classes like:
\d
??-E saves me :)
sed -E 's/([0-9]{4} )([0-9]{4} )([0-9]{4} )([0-9]{4})/\4 \3\2\1/g'
-E and -e what is difference??????
-E lets you use extended regular expressions, so you don’t need to escape things like {}, +, or (). -e lets you write one or more sed commands — it’s used to pass multiple commands to sed. So: -E = easier regex -e = multiple commands