i guess it's all related to the split or the join
I would guess so too. You split on /\s+/ but you join with " " so there's clearly going to be a change in the whitespace there if you have anything other than single whitespaces between the words in your input.
Since you check for \b anyway, why not split on that instead and then check each field for an alpha character before doing your comparison? You could then join on ''.
Alternatively look into using one of the many text parsing modules.
In reply to Re: Preserve original text formatting.
by hippo
in thread Preserve original text formatting.
by larsb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |