in reply to Re: Getting around "/" as a word boundary
in thread Getting around "/" as a word boundary

Hi ikegami, I am a perl beginner, I don't get the following regex very much. Can you explain the (?<!/) part in detail? Thanks in advance.

$doc2=~s#(?<!/)\b($_)\b#$1/$hashstore{uc($_)}#ig;

Replies are listed 'Best First'.
Re^3: Getting around "/" as a word boundary
by AnomalousMonk (Archbishop) on Aug 12, 2010 at 08:48 UTC

    This is a "zero-width, look-behind assertion". The assertion is true if  (?<!/) does not immediately follow a '/' (forward slash) character at the point at which the assertion occurs in the regex.

    See  (?<!pattern) in the Extended Patterns section (in the Look-Around Assertions subsection) of perlre.

    Update: Added "zero-width" to description.

Re^3: Getting around "/" as a word boundary
by ikegami (Patriarch) on Aug 12, 2010 at 16:14 UTC
    "(?<!/)" means "not immediately preceded by '/'"