BeRo1985 / flre

FLRE - Fast Light Regular Expressions - A fast light regular expression library
GNU Lesser General Public License v2.1
94 stars 23 forks source link

split trailing match #13

Closed benibela closed 8 years ago

benibela commented 8 years ago

If you do a simple split with TFLRE.Create('#', []), both 'a' and 'a#' split to the same single element array ['a']. so you cannot join it back together to get the original input. I think the latter should give ['a', '']

BeRo1985 commented 8 years ago

Okay, I'll try to fix that in the next minutes or hours.

BeRo1985 commented 8 years ago

Changed/improved in lastest commit, but keep it in mind, that FLRE's Split behaviour is now like ECMAScript/JavaScript's String.split and not PHP's preg_split.

benibela commented 8 years ago

So now it is supposed to insert the captures in the splitted array ? That is not what I need either :(

BeRo1985 commented 8 years ago

For example:

splitting a#b#c#d by regex # => ['a','b','c','d'] splitting a#b-c#d- by regex #(\w*)- => ['a','b','c','d']

Just read your favorite ECMAScript/JavaScript reference on the String.split() topic, because the FLRE split function works nearly exactly like ECMAScript/JavaScript's String.split().

And when you don't use capture groups or when you do use just non-capturing (?:) groups, then the FLRE split function act also similiar like PHP's preg_split or any another 08/15 split function in any other framework or language ecosystem.

benibela commented 8 years ago

splitting a#b-c#d- by regex #(\w*)- => ['a','b','c','d']

splitting a#b-c#d- by regex #(\w*)- => ['a','b','c','d', '']

Just read your favorite ECMAScript/JavaScript reference on the String.split() topic, because the FLRE split function works nearly exactly like ECMAScript/JavaScript's String.split().

But I need XQuery's tokenize