I have the following text in the data.txt file
:MENU1
0. public
1. admin
2. webmail
:SYNTAX
! opt1, ... :
:ERROR1
Error #1, blah... blah.. blah...
Please do ...
:ERROR2
Error #2 ...
and I want to use a regular expression (PERL syntax) to extract the part from :MENU1
to the next first :
, but dropping MENU1
and the last :
from the result.
Been trying several regex's but in the closest solution I got I can't put the 'greedy' option to work and cant't discard the last ":"
grep -Poz "^:MENU1\K[\w\W]*:"
this works with grep ...
but brings all the text until the last ":" ...
I want only until the next first ":" after :MENU1
:
0. public
1. admin
2. webmail
(note the final blank line)
\n
after:MENU1
and before the first:
, should those be included? Please edit your question and show us your desired output. – terdon♦ Sep 30 '15 at 18:09