-1

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

Alan Moore
  • 73,866
  • 12
  • 100
  • 156
Nithin
  • 921
  • 3
  • 10
  • 17

2 Answers2

0
<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=\"\(.*\)\".*>
moongoal
  • 2,847
  • 22
  • 23
  • actually i want to check xml node starting .so i want regular expression equivalent to this to so that i can replace this with another one such as – Nithin Nov 10 '11 at 15:34
  • Try with this new one, I succesfully used it with JS. – moongoal Nov 10 '11 at 15:58
  • Regex="<Prop Display =\"\ Monitor\" id=\"\1\" >(.*?)</Prop>".i tried like this but it is not working .the problem is due t the double quotes.how to represent double quotes using regular expression – Nithin Nov 11 '11 at 05:16
  • Where are you using this expression? The syntax has little differences depending on the program/API you use.. Usually double quotes are represented by escaping them, such as: \" – moongoal Nov 11 '11 at 09:38
-1

I think this should work to match the string:

pro\sdispl=["]monitor["]\sid=["]1["]
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
rl22
  • 1
  • i tried like this (("[^"]*")for doubles quotes but it is showing some error in msbuild.i think that error is due to the [ square bracket. – Nithin Nov 10 '11 at 15:45