in reply to Another regex needed

I am learning regexs myself so you should use my code as an idea rather than as something that's going to work :)

I would write something like  m/[*(.*)*]+ $1/g; I *think* that is saying, match *, any character any number of times, * and it stores that into $1. I through the brackets in there because my original code was *(.*)* + $1/g; which doesn't look like the correct syntax.

Anywhere, use this as an idea because I'm sure it doesn't work. Hope this helps!

"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re: Re: Another regex needed
by BUU (Prior) on Sep 20, 2003 at 21:06 UTC
    Actually what your regex does is match either an asterisk, an open parentheses, a dot, or a close parentheses, (which is to say: * ) ( .) and do it one or more times. Followed by white space and then what happens to be in $1 at the time. This because the square brackets create a character class out of their contents. Please read perlre for more on character classes. Your original code was much closer to your intent, except that you would have needed to escape the asterisks in order to match literal asterisks in the text, as asterisks are meta chars. However even if you escaped them it still wouldn't work perfectly, please see death to dot star! for more.