From the given paragraph of text, write a program to match
the strings of format “Any number of numerals followed by
an underscore followed by any number of alphabets"
ex:123_abc
(Note:using regular expressions)
Answers were Sorted based on User's Feedback
Answer / kp
private void RegExp(string input)
{
string s = input;
Regex regexp = new Regex("^[0-9]*_[A-Za-z]*$");
if(regexp.IsMatch(input))
Console.WriteLine("Matched");
else
Console.WriteLine("Not Match");
}
Is This Answer Correct ? | 19 Yes | 2 No |
Answer / raghuram
both the above answers are wrong....... Reg Exp should say..
new Regex("[0-9]*_[A-Za-z]*");
^ and $ mean beginning and end of a line... and the question
is to select that particular combination no matter where
they are present...... need not be entire line.
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / thanvir
private void RegExp(string input)
{
string s = input;
Regex regexp = new Regex("^[0-9]*_[A-Za-z]*$");
if(regexp.IsMatch(input))
Console.WriteLine("Matched");
else
Console.WriteLine("Not Match");
}
Is This Answer Correct ? | 3 Yes | 2 No |
Answer / pio
Raghuram is right and his regex is 100% correct. The other
2 answers also have a string which does nothing:
string s = input;
so it is not necessary.
Is This Answer Correct ? | 1 Yes | 1 No |
what is clr .
Interface have Default Modifier Is 'Public'.Where We Will Use The KeyWord In Interface?
3 Answers Phoenix Technologies,
Explain server control extensibility with reference to asp.net 2.0 ?
What are the security types in ASP/ASP.NET? Different Authentication modes?
I am using a range validator and want to use dd mm yyyy format for accepting dates. I get a fairly generic "can't do that" type exception when I use this format for setting the minValue or maxValue properties for the range validator. How can I force it to accept my format?
under which namespaces connection strings can be defined?
What is intrinsic objects in asp.net?
Is asp.net mvc front end or backend? : Asp.Net MVC
what is difference between const, static and readonly?
What are the two types of web pages?
Describe state management in asp.net?
What is a postback in asp net?