473,568 Members | 2,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex("(");

Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?

Mark Johnson, Berlin Germany

mj*****@mj10777 .de
Nov 16 '05 #1
5 2017
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/
"Mark Johnson" <mj*****@mj1077 7.de> wrote in message
news:41******** *************** @newsread4.arco r-online.net...
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?

Mark Johnson, Berlin Germany

mj*****@mj10777 .de

Nov 16 '05 #2
Bad idea. Character sets are usually slower (more complex) than plain
characters.
Simply use escapes: Regex(@"\(");
That's it.
BTW: That works for all the special charaters like *+.\ and so on.

Niki

"Steve Willcock" <st***@N-O-S-P-A-Mwillcockconsul ting.com> wrote in
news:cf******** ***********@new s.demon.co.uk.. .
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/
"Mark Johnson" <mj*****@mj1077 7.de> wrote in message
news:41******** *************** @newsread4.arco r-online.net...
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?

Mark Johnson, Berlin Germany

mj*****@mj10777 .de


Nov 16 '05 #3
True, although the original regex had a @ in the quotes so (if this was
intentional) this should be:

Regex(@"@\(");

Obviously the first @ is to tell C# to use a literal string and not to treat
the \ as a C# string escape code.

Steve

"Niki Estner" <ni*********@cu be.net> wrote in message
news:OI******** ******@TK2MSFTN GP11.phx.gbl...
Bad idea. Character sets are usually slower (more complex) than plain
characters.
Simply use escapes: Regex(@"\(");
That's it.
BTW: That works for all the special charaters like *+.\ and so on.

Niki

"Steve Willcock" <st***@N-O-S-P-A-Mwillcockconsul ting.com> wrote in
news:cf******** ***********@new s.demon.co.uk.. .
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/
"Mark Johnson" <mj*****@mj1077 7.de> wrote in message
news:41******** *************** @newsread4.arco r-online.net...
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?

Mark Johnson, Berlin Germany

mj*****@mj10777 .de



Nov 16 '05 #4
Regex r = new Regex("@[(]");

did not work, but
Regex r = new Regex("[(]");

did.

Thank You.

Mark Johnson, Berlin Germany
mj******@mj1077 77.de

"Steve Willcock" <st***@N-O-S-P-A-Mwillcockconsul ting.com> schrieb im
Newsbeitrag news:cf******** ***********@new s.demon.co.uk.. .
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/
"Mark Johnson" <mj*****@mj1077 7.de> wrote in message
news:41******** *************** @newsread4.arco r-online.net...
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?

Mark Johnson, Berlin Germany

mj*****@mj10777 .de


Nov 16 '05 #5
Yes, this works ass well. I got the @ in the wrong position.

Mark Johnson, Berlin Germany
mj*****@mj10777 .de

"Niki Estner" <ni*********@cu be.net> schrieb im Newsbeitrag
news:OI******** ******@TK2MSFTN GP11.phx.gbl...
Bad idea. Character sets are usually slower (more complex) than plain
characters.
Simply use escapes: Regex(@"\(");
That's it.
BTW: That works for all the special charaters like *+.\ and so on.

Niki

"Steve Willcock" <st***@N-O-S-P-A-Mwillcockconsul ting.com> wrote in
news:cf******** ***********@new s.demon.co.uk.. .
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/
"Mark Johnson" <mj*****@mj1077 7.de> wrote in message
news:41******** *************** @newsread4.arco r-online.net...
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?

Mark Johnson, Berlin Germany

mj*****@mj10777 .de



Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.