|
-
April 10th, 2003, 11:12 AM
#1
Regular expression
Look at this code...
==============================================
string strClaim = "BER";
Regex objNaturalPattern = new Regex("[Bb][Ee][Rr]|[Tt][Ww][Oo]|[Ss][Tt][Oo]");
objNaturalPattern.IsMatch(strClaim);
==============================================
ok the return value to "objNaturalPattern.IsMatch(strClaim);" will be true as it matches [Bb][Ee][Rr]. Now what I might want to do and it needn't only apply to this example is know which Regular expression ([Bb][Ee][Rr]|[Tt][Ww][Oo]|[Ss][Tt][Oo])the string matched.
Is there any possible way to get some kinda of return value to say which one was matched?
as in a string matching [Bb][Ee][Rr] would return 0
as in a string matching [Tt][Ww][Oo] would return 1
as in a string matching [Ss][Tt][Oo] would return 2
no match could return -1
Is this posible? Is there a method that I have over looked?
elp!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|