in reply to broken regex

As the man said, we need your data to be able to tell something about this. From looking at your regex (mangled by the fact that it's not in code tags), it seems like it is not looking for a word, but for a word preceded and followed by a % or a digit. Is that what you intend to do?


Replies are listed 'Best First'.
Re^2: broken regex
by elwood (Initiate) on Sep 15, 2006 at 12:54 UTC
    sorry about the bad formatting, I'll try again
      foreach (@words) {
        $line =~ s/(%\d)$_(%\d)//g;
        print "$line\n";

    It was my understanding that (%\d) detected a word boundary (space, begining of line, end of line)
      That's why we're here. \b is the word boundary metacharacter. And thanks for the code tags! :)


        doh! of course! something about not seeing the forest for the trees :-)

      sorry about the bad formatting, I'll try again

      On PerlMonks, put <c>..</c> tags around your code. It's like <pre>..</pre>, but it handles escaping special characters for your (such as &, <, >, [ and ]). It also wraps long lines while offering a link to download the unwrapped version.

        Whereas using <pre></pre> can completely foul things up with long lines!

        Welcome to the monastery, I hope you find the place as useful as I have over the years.