in reply to Possible to use "split", but save the delimiter?

If you capture bracket the split regex, the delimiters will be retained:

$s = "this.that,the other; and this! as well";; @bits = split /([.,;!])/, $s;; $_ !~ /[.,;!]/ and $_ = uc for @bits;; print join'',@bits;; THIS.THAT,THE OTHER; AND THIS! AS WELL

A pointless example, but it demos the technique.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"