Reputation: 18848
I am trying to write the pattern matcher for the below string
show int sh 1/1/06
SHDSL 1/1/6
Description 3599979
Constellation (bits/baud) 30
I need to get the value of 'show int sh' and 'SHDSL' and 'Description' and so on...
It should shrink the white spaces and get the value of respective strings.
Can any one guide me to write the regex pattern for the same.?
Upvotes: 0
Views: 308
Reputation: 32797
You can use this regex in multiline mode
^show int sh\s*(.*)$
^show int sh\s*
checks for show int sh
at the start ^
of the line before the required data
\s*
matches 0 or more space till the first non space character
(.*)$
captures the required value till end of the line$
in group 1
So here are all the regex's
Use multiline mode
^show int sh\s*(.*)$
^SHDSL\s*(.*)$
^Description\s*(.*)$
^Constellation\s*(.*)$
OR a single regex
^((show int sh|SHDSL|Description|Constellation)\s*).*$
Upvotes: 1