fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var text = "Morelines\n\nWe have considered the applica\t\r\nnt's experience and qualification, \nand wish to grant him an interview.";
  12. Console.WriteLine(string.Format("Our text:\n{0}\n---------", text));
  13. var search = "applicant";
  14. var pattern = string.Join(@"[\t\r\n]*", search.ToCharArray());
  15. Console.WriteLine(string.Format("Our pattern: {0}\n----------", pattern));
  16. var result = Regex.Match(text, pattern);
  17. if (result.Success) {
  18. Console.WriteLine(string.Format("Match: {0} at {1}\n----------", result.Value, result.Index));
  19. var lineNo = Regex.Split(text.Substring(0, result.Index), @"\r?\n|\r").GetLength(0);
  20. Console.WriteLine(string.Format("Line No: {0}", lineNo));
  21. }
  22. }
  23. }
Success #stdin #stdout 0.03s 30264KB
stdin
Standard input is empty
stdout
Our text:
Morelines

We have considered the applica	
nt's experience and qualification, 
and wish to grant him an interview.
---------
Our pattern: a[\t\r\n]*p[\t\r\n]*p[\t\r\n]*l[\t\r\n]*i[\t\r\n]*c[\t\r\n]*a[\t\r\n]*n[\t\r\n]*t
----------
Match: applica	
nt at 34
----------
Line No: 3