in reply to regex trouble
Your description is such a mess due to bad HTML that I'm not sure what you really want to do, but most likely your problem is that \Q quotes meta characters so that the contents of $pattern are treated as a string to match. Omit \Q and in this case your life may be happier.
You also need to quote all the meta characters in $pattern and you need to "double quote" in a double quoted string: "(,|\\||:|>|\\]\\[|_\\|_)" so the quote character is available to be parsed by the regex engine. The two changed lines then become:
my $pattern= "(,|\\||:|>|\\]\\[|_\\|_)"; my @splitted= split /$pattern/,$text;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex trouble
by blazar (Canon) on May 30, 2007 at 11:49 UTC | |
by GrandFather (Saint) on May 30, 2007 at 20:43 UTC |