regular expressions

  • Thread starter Thread starter Iwan Petrow
  • Start date Start date
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.
 
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
 
Back
Top