Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace Krisi
- {
- class Program
- {
- static void Main(string[] args)
- {
- string value = change("draganpenchogosho", "pencho", "dragan", "gosho");
- if(value != null)
- {
- string awnser = value.Substring(1, value.Length - 2);
- Console.WriteLine("The given substring is: " + awnser);
- }
- else
- {
- Console.WriteLine("There is no such match!");
- }
- }
- static string change(string S, string X, string A, string B)
- {
- string regex = "[" + A + "|" + B + "]" + X + "[" + A + "|" + B + "]";
- if (S.Contains(X))
- {
- Match match = new Regex(regex).Match(S);
- string value = match.Value;
- return value;
- }
- else
- {
- return null;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement