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 dataset and uses of dataset ?
What namespaces are imported by default in ASMX files?
Is react a template engine?
What is work flow gen? how can it will work with .Net?
what are the ways to improve performance in .net application?
Can we add code files of different languages in app_code folder?
Can you explain page lifecycle in net?
What are the Types of authentications in IIS
Explain the main function of url routing system in asp.net mvc? : asp.net mvc
How can we provide the WebParts control functionality to a server control?
What are sessions and cookies?
Is It Possible For Whole Page is Saved In View State? What Is View State?
2 Answers Phoenix Technologies,
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)