regex - Grepping for a pattern followed by another pattern and excluding what lies inbetween as ouput -


i want

egrep -o '(mon|tues)[1-3]?[0-9].*(mon|tues)[1-3]?[0-9]' 

and isn't found (mon|tues)[1-3]?[0-9]

with input

mon19hellotues20 mon19world hellomon19 tues8worldtues22 

i want

mon19tues20 tues8tues22 

as output

sed better tool print matched txt in output:

sed -ne 's/(mon|tues)([1-3]{0,1}[0-9]).*(mon|tues)([1-3]{0,1}[0-9])/\1\2\3\4/p' file  mon19tues20 tues8tues22 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -