regular expressions

I

Iwan Petrow

Hi,

I have a string and I want to check wether the whole string satisfies
given conditions. I use regular expression and IsMatch() but it matches
and if the string contains the pattern and other symbols. For example I
want to match this: "John Smith go there". I use regex pattern
"([A-Za-z]+\s)+". IsMatch() rturns true and here "John Smith go
there.!@#$..".

What could I do to check for whole strings (not part them) ?


Thanks.
 
H

Hans Kesting

Iwan said:
Hi,

I have a string and I want to check wether the whole string satisfies
given conditions. I use regular expression and IsMatch() but it
matches and if the string contains the pattern and other symbols. For
example I want to match this: "John Smith go there". I use regex
pattern "([A-Za-z]+\s)+". IsMatch() rturns true and here "John Smith
go there.!@#$..".

What could I do to check for whole strings (not part them) ?


Thanks.

Set ^ and $ around your regexp:
^ matches the beginning of the input string,
$ matches the end of the input string.

Hans Kesting
 

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