I'm trying my best to read your regex "correctly" (resorting to "View Page Source" in my browser until you or one of the janitors puts it into <code>...</code> tags), but I think you basically have it all completely wrong... It seems to start like this:
s/(.{$len}[...
(note the square bracket) and end like this:
...])/$1<wbr>/mgi;
which means that all those backslashes, parens, curlies with digits, and vertical-bar alternations are actually inside a character class. (If you don't understand what that means, you need to spend some time with perlretut and perlre.)

To make matters worse, you even seem to be trying to use embedded square brackets, which really cannot be right -- that in itself might not be a syntax error, but it simply will not work. (The PM formatting logic turned the square brackets surrounding "a-z" into an anchor tag, which wouldn't happen if you used code tags around the code.)

So, the regex in its original form is trash. Start over. What are you really trying to accomplish? What is the input data? What is the intended output?


In reply to Re: Strange regexp problem by graff
in thread Strange regexp problem by rocketman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.