TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
steve
NA
5
0
Regex with wildcards in string and regex
Jul 26 2010 9:38 AM
Trying to do a match between two strings when both the strings have * wildcards. E.g. license plates witness 1 sees A*23* and withness 2 sees *123*Z. I want these to flag up as a match.
e.g. if I niavely do
string plate = "A.*23.*";
Regex r1 = new Regex(@".*3.*");
Console.WriteLine(r1.IsMatch(plate));
Regex r2 = new Regex(@"A123");
Console.WriteLine(r2.IsMatch(plate));
Regex r3 = new Regex(@".*Z");
Console.WriteLine(r3.IsMatch(plate));
Regex r4 = new Regex(@".*123.*Z.*");
Console.WriteLine(r4.IsMatch(plate));
then I get
true
false
false
false
whereas I want them all to be true. The problem is a bit more complex than this, but understanding how to deal with wildcard in the original string (not just the regex) would be a good start. Any ideas?
Reply
Answers (
4
)
sql procedure connection to c#
what is difference between shadows and private?