Splitting without getting delimiters in array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

I use a regex (?<!\\?)('|\\+|:) to split a string to a String[].

The String[] i get after splitting is correctly splitted but contains all
the delimiters i use to decide where the string should be splitted.

Do I have to loop through the array and find every index containing a single
delimiter or is there a easier way to do this.

Regards / gustav
 
According to the documentation, if you employ capturing groups in the
Regular Expression (which you did), it will include the groups in the array.
Try this instead:

(?<!\?)['+:]

It uses a character class to determine the delimiter characters, without
grouping.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
Back
Top