in reply to Regex not matching &

\b is only going to find a work boundary for you if you agree with what \w thinks is a word character. If you want to have an expanded notion of what is a word, using \b is not going to do what you want.

In this case, I don't see any need for it at all, though. Just removing the \b's should do what you want. Perhaps add [;&\w] at the end if you don't want it to end with a hyphen.

Your regex will set $1 to everything from the first hyphen on, or to the last character of the "word" if there were no hyphens. That seems kind of bizzare. Are you using $1? If so, exactly which part of the word to you want it to contain? If not, you can simplify it to m/[;&\w][-;&\w]+/g, or if you mean to only match hyphenated words, m/[;&\w]+-[-;&\w]+/g.

Your //s and //i flags have no effect with your regex.

Replies are listed 'Best First'.
Re: Re: Regex not matching &
by murugu (Curate) on Mar 19, 2004 at 02:57 UTC

    Thaks for all of ur responses

    Right now it is working just by removing the starting \b. I hve finished the work now.

    Once again thanks guys

    --Murugesan--

      so how would I just match the & character?