fork download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var str = "FIND files where file2=29 AND file32=\"12\" OR file623134=\"file23\"";
  10. var rx = new Regex(@"\bfile(\d+)=""?(\w+)""?");
  11. var result = rx.Replace(str, "(FILE_ID=$1 AND FILE_VALUE=$2)").Replace("FIND files where", "SELECT * FROM [FILES] WHERE");
  12. Console.WriteLine(result);
  13. }
  14. }
Success #stdin #stdout 0.11s 24944KB
stdin
Standard input is empty
stdout
SELECT * FROM [FILES] WHERE (FILE_ID=2 AND FILE_VALUE=29) AND (FILE_ID=32 AND FILE_VALUE=12) OR (FILE_ID=623134 AND FILE_VALUE=file23)