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

Where can I get information on cookies in asp.net?

0 Answers  


how to add cliet side event to server side? and how to register client script to sever side? wt difference these two

3 Answers   PSI Data Systems,


what is session . how it is use ?

3 Answers   TCS,


Define xmlvalidatingreader class.

0 Answers  


What is dataset and uses of dataset ?

6 Answers   HCL, TCS,






Can we store object in viewstate?

0 Answers  


How long the items in ViewState exists?

0 Answers   SwanSoft Technologies,


What is the difference between exe and dll?

0 Answers  


when user is logged on the information is saved in a cookie, what is the name of that cookie?

5 Answers   Mind Tree,


What is meant by asp.net?

0 Answers  


Name and describe some HTTP Status Codes and what they express to the requesting client ?

1 Answers  


Can the action attribute of a server-side tag be set to a value and if not how can you possibly pass data from a form page to a subsequent page?

1 Answers  


Categories