Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace Krisi
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string value = change("draganpenchogosho", "pencho", "dragan", "gosho");
  11. if(value != null)
  12. {
  13. string awnser = value.Substring(1, value.Length - 2);
  14. Console.WriteLine("The given substring is: " + awnser);
  15. }
  16. else
  17. {
  18. Console.WriteLine("There is no such match!");
  19. }
  20. }
  21. static string change(string S, string X, string A, string B)
  22. {
  23. string regex = "[" + A + "|" + B + "]" + X + "[" + A + "|" + B + "]";
  24. if (S.Contains(X))
  25. {
  26. Match match = new Regex(regex).Match(S);
  27. string value = match.Value;
  28. return value;
  29. }
  30. else
  31. {
  32. return null;
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement