How to emulate PHPs preg_split in ruby to capture offsets and delimiters?
- by dimus
I wonder if there is a way to get offsets and delimiters while I am splitting a string in ruby analagous to PHP preg_split:
preg_split("/( | |<|>|\t|\n|\r|;|\.)/i", $html_string, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE);
I imagine I can achieve it by traversing string by characters or using something heavy as treetop, but I would like to use something more convenient.