in reply to Re: RegEx to match at least one non-adjacent term
in thread RegEx to match at least one non-adjacent term

Thanks for the info on Regexp::List. I need to get more familiar with the modules that are out there.

I think your initial solution would end up always leaving a space where the word was? That's fine if the word was between two number but not if it was at the beginning or end. I'm happy with the cheap trim I get from removing spaces along with the bad words.

If I'm wrong about it always leaving a space, I appologize. I am committing the sin of commenting without executing the example as I don't have access to Perl on my internet connected machine.

  • Comment on Re^2: RegEx to match at least one non-adjacent term

Replies are listed 'Best First'.
Re^3: RegEx to match at least one non-adjacent term
by ikegami (Patriarch) on Dec 07, 2007 at 17:09 UTC

    Yes it does, in order to avoid "1234 Red 5678" becoming "12345678". Feel free to remove extra whitespace afterwards. Doing it in the regex would needlessly complicate it.

    s/.../ /xg; s/^\s+//; s/\s+$//;