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

It also accepts an empty string, since you've got a doubled '|' in there. One | separates alternatives, not two.

As for dumbing it down, I'd rewrite it like so:

$A_rx = qr{ \Q $A }x; $w_rx = qr{ \Q $w }x; $rx = qr{ $A_rx \s* \*? \s* cos \s* (?: \( \s* $w_rx \s* \*? \s* t \s* \) | $w_rx \s* \*? \s* t \s ) \s* A }x;
Then you can use it in the following manner: $string =~ /^\s*($rx)\s*$/.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: is there an easy way to dumb down this regular expression for me?
by diotalevi (Canon) on Oct 19, 2005 at 20:42 UTC

    A nit - you'll notice that $re is assigned '/.../', not a qr expression. I prefer your assignment of the qr// but its worth noting.

Re^2: is there an easy way to dumb down this regular expression for me?
by moltar512 (Sexton) on Oct 19, 2005 at 20:48 UTC
    thanks! but i have to ask a few more questions yours is infintely more easy to read.. but now i'm trying to figure out what you did using http://www.perlmonks.net/?node=perlop what does the x behind all of your qr{ ... }x mean?
      Look at perlre as well for the /x modifier:
      x Extend your pattern's legibility by permitting whitespace and comments.
      It was used so that everything could be spaced out for clarity -- that's also why al the \s* are in there because when using /x you have to explicitly say when you actually want to match whitespace.