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



From the given paragraph of text, write a program to match the strings of format “Any number of ..

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

From the given paragraph of text, write a program to match the strings of format “Any number of ..

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

From the given paragraph of text, write a program to match the strings of format “Any number of ..

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

From the given paragraph of text, write a program to match the strings of format “Any number of ..

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

Post New Answer

More ASP.NET Interview Questions

what is clr .

1 Answers   Patni,


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 ?

0 Answers  


What are the security types in ASP/ASP.NET? Different Authentication modes?

0 Answers  


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?

1 Answers   FutureTech,






under which namespaces connection strings can be defined?

4 Answers  


What is intrinsic objects in asp.net?

0 Answers  


Is asp.net mvc front end or backend? : Asp.Net MVC

0 Answers  


what is difference between const, static and readonly?

2 Answers   TVS,


What are the two types of web pages?

0 Answers  


Describe state management in asp.net?

0 Answers  


What is a postback in asp net?

0 Answers  


Categories