I’m new to regular expressions in c# and can’t get even basic searchs to
work as I believe they’re supposed to. The following example is where I
try to identify any word in a string:
this.filecontent = "the cat sat on the mat";
this.MethodSpotter = new Regex("(\\w+)",RegexOptions.IgnoreCase);
MatchCollection result = this.MethodSpotter.Matches
(this.filecontent);
The result is that I get an Unhandled exception saying item has already
been added.
The following example returns the entire string rather than just the
word “cat”, surely such behaviour is incorrect?
this.filecontent = "the cat sat on the mat";
this.MethodSpotter = new Regex("cat",RegexOptions.IgnoreCase);
MatchCollection result = this.MethodSpotter.Matches
(this.filecontent);
Also how do I ensure that a string must finish with a particular
character? The $ operator just seems to be ignored.
Many thanks for any assistance you may be able to offer.
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!