in reply to substitutions with unknown data

\b finds boundaries between \w and \W characters. What you want instead is:

/(?<!\S)\Q$face\E(?!\S)/

which means that the face can't be preceeded by a non-space characters [like (?<=\s) except it allows $face to appear at the front of the message] and can't be followed by a non-space characters [like (?=\s|$)].

- tye        

Replies are listed 'Best First'.
Re^2: substitutions with unknown data (\b is \w not \s)
by sulfericacid (Deacon) on Mar 28, 2005 at 20:37 UTC
    Thanks for that code. I inserted it but I'm still having the same problem. I'll keep using it though since it's definitely better than what I was using.

    I insterted a little test to do a printout of the faces to make sure we are using the right data.

    I added

    my ($username, $message, $date, $ip) = split(/<!!>/, $line); while ($sth->fetch) { $message =~ s|(?<!\S)\Q$face\E(?!\S)| <img src="$location" alt=" +$name"> |gi; print "$face<br>"; }
    And the output was
    *Crying* :) :( :P :O *hug* *flower* ;) *evil* *love* *yawn* 0<- albie *thumb* *angel* *cool* pix action test test: oh pix: emoticon :) test pix: emoticon :) test test: *hug* test: *hug* test: *hug* test: *hug* test: test :) here *hug* test test: test :) here *hug* test
    So the $face data IS right but it's still not doing any of the s/// in the data. Any other suggesitons?

    Thanks.



    "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

      This wouldn't show if you had spaces in your "face" strings, for example.

      For a situation like this, I'd probably just use "perl -d", set a break point at the loop and use "x $message" and "x $face" a couple of times.

      But you can also use something like Data::Dumper to get some more precise information about your data.

      - tye