Regex("(");

M

Mark Johnson

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

How do you serarch for a ( with Regex ?



Mark Johnson, Berlin Germany

(e-mail address removed)
 
S

Steve Willcock

Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");
 
N

Niki Estner

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 said:
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/


Mark Johnson said:
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?



Mark Johnson, Berlin Germany

(e-mail address removed)
 
S

Steve Willcock

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 said:
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 said:
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/


Mark Johnson said:
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?



Mark Johnson, Berlin Germany

(e-mail address removed)
 
M

Mark Johnson

Regex r = new Regex("@[(]");

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

did.

Thank You.

Mark Johnson, Berlin Germany
(e-mail address removed)





Steve Willcock said:
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/


Mark Johnson said:
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?



Mark Johnson, Berlin Germany

(e-mail address removed)
 
M

Mark Johnson

Yes, this works ass well. I got the @ in the wrong position.

Mark Johnson, Berlin Germany
(e-mail address removed)

Niki Estner said:
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 said:
Mark, try putting the ( in square brackets - e.g.
Regex r = new Regex("@[(]");

--
Steve Willcock, MCSD
http://www.willcockconsulting.com/


Mark Johnson said:
Regex("@("); brings an error (missing ")").

How do you serarch for a ( with Regex ?



Mark Johnson, Berlin Germany

(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top