[plt-scheme] Howto regexp-split string but keep delimiters
On Nov 21, Erich Rast wrote:
> Hello all,
>
> I need to split a large string into separate words using a regexp, but
> need to keep non-whitespace delimiters:
>
> "Ab, c, dd,hello." ==> ("Ab" "," "c" "," "dd" "," "hello" ".")
>
> Can this be done using regexp-split? How?
It's easier to do with regexp-match:
> (regexp-match* #px"[\\w]+|[^\\s\\w]" "Ab, c, dd,hello.")
("Ab" "," "c" "," "dd" "," "hello" ".")
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!