64 765
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #5712 in C# for Jatin

Question #5712
I need a function that can extract string starting with "$" and ending with " ' " or "," or nothing

Suppose string is

efgh = '$EXPCH.nmo' AND tree = $Name, tree = $pcd

it should return me
EXPCH.nmo
Name
pcd

Any help please...
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace q5712
{
class Program
{
& static void func(char[] str)
& {
char[,] new_str = new char[10, str.Length];
int n = 0;
for (int i = 0; i < str.Length; i++)
{
if (str[i] == '$')
{
& i++;
& int j = 0;
& while(str[i] != ',' && str[i] != (char)39)
& {
new_str[n, j] = str[i];
j++;
i++;
if(i == str.Length)
break;
& }
& n++;
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; new_str[i, j] != '\0'; j++)
& Console.Write(new_str[i, j]);
Console.WriteLine();
}
& }

& static void Main(string[] args)
& {
string str1;
Console.WriteLine("Enter string: ");
str1 = Console.In.ReadLine();
func(str1.ToCharArray());
& }
}
}

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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions