76 327
Assignments Done
Successfully Done
In May 2019

Answer to Question #15902 in C# for leena

Question #15902
write a prg that accepts 2 strings from the user. Also write code to print positions of all occurrences of the second string in the fisrt string using regular experssion.
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Occurrences_of_the_second_string_in_the_fisrt
class Program
static void Main(string[] args)
string firststring="";
string secondstring = "";
Console.Write("Enter first string: ");
firststring = Console.ReadLine();
Console.Write("Enter second string: ");
secondstring = Console.ReadLine();
Regex FindA = new Regex(secondstring);
int count = 0;
foreach (Match Tag in FindA.Matches(firststring))
Console.WriteLine("Found "+secondstring+" at {0}", Tag.Index);
if (count == 0) {
if (count > 0) {
Console.WriteLine("Not found ");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions