in reply to is there an easy way to dumb down this regular expression for me?

You had a bug. The alternation || is only written with *one* pipe character. The zero length pattern between each of the |s is also available so you could match anything that /^\s*$/ would match. The \Q...\E means quotemeta(). I've removed the \Q$A\E by doing quotemeta outside teh regexp. Since quotemeta has no effect on stuff like t and A, I removed it from those as well. I factored out the common parts of the expression so they aren't repeated. I also used the /x flag so I could add in as much extra whitespace as a I want - makes it easier to read. You'll notice how now everything except one branch of the alternation is followed by optional whitespace. That's to prevent "tA" from matching.

$A = quotemeta -4; $w = quotemeta 500; $re = '/^ \s* $A \s* -? \s* cos \s* (?: \( \d+ t \) | \d+ t \s ) \s* A \s* $/x;
  • Comment on Re: is there an easy way to dumb down this regular expression for me?
  • Download Code