Here is how I would do it:
quotePattern = { "\"" , "'", "" };
stringPattern = quotePattern ~~ __ ~~ "by" ~~ __ ~~ quotePattern;
StringMatchQ[ #, stringPattern ] & /@ { "x by y", "\"x by y\"", "'x by y'" }
{ True, True, True }
Here is how I would do it:
quotePattern = { "\"" , "'", "" };
stringPattern = quotePattern ~~ __ ~~ "by" ~~ __ ~~ quotePattern;
StringMatchQ[ #, stringPattern ] & /@ { "x by y", "\"x by y\"", "'x by y'" }
{ True, True, True }