how to represent following string using regular expression?

1.4k views Asked by At

I want to represent following string using regular expression.

This is the sentence:

pro displ = "monitor" id="1"

I tried this:

pro displ=(("[^"]*")monitor(("[^"]*") id =(("[^"]*")1(("[^"]*")

but it is not working.as i was new to regular expression please help me to solve this issue

2

There are 2 answers

4
moongoal On
<prop.*disp=\"(.*)\".*id=\"(.*)\".*>

You can use this one, and then match the parentheses to change what you want.

Instead this one with the 'sed' utility:

<prop.*disp=\"\(.*\)\".*id=\"\(.*\)\".*>
1
rl22 On

I think this should work to match the string:

pro\sdispl=["]monitor["]\sid=["]1["]