469,632 Members | 1,730 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

Regex Matching Problems.

Visual Basic.NET Framework 2.0
I've created a program to parse out text as the program recieved it and use Regex matching to decide what should be done. My problem is that the text is matching when it shouldn't be, if that makes any sense.

Expand|Select|Wrap|Line Numbers
  1. If Regex.IsMatch(Text, "You find (a|an)" & MoneyMatch) Then
  2.      Other code here that doesn't matter.
  3. ElseIf Regex.IsMatch(Text, "([A-Z][a-z]+\s)obtains (a|an)") Then
  4.      More code that doesn't matter.
  5. EndIf
I don't have a deep understanding of Regex, but I've been working on it as I go. In this example, MoneyMatch is a series of items, separated by the | operator. There are two types of lines that enter the program, and are formatted as follows:

You find (a|an) MoneyMatch (string).
([A-Z][a-z]+\s) obtains (a|an) MoneyMatch.

The problem is that both lines are matching to the first case. I had thought that my first Regex.IsMatch required that the line match "You find a Money", so it would exclude the second case. I believed that the error may be in the "IsMatch" part of the code. I assumed that required a full line match, but is a partial match enough to get a return value?

Any help is appriciated.
Oct 20 '06 #1
0 1340

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by aeuglein | last post: by
7 posts views Thread by bill tie | last post: by
5 posts views Thread by Kofi | last post: by
17 posts views Thread by Mark | last post: by
1 post views Thread by Chris Newman | last post: by
16 posts views Thread by Mark Chambers | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.