Click here to Skip to main content
15,882,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
segments=re.split('(\([A-Za-z0-9]*\)[0-9]*)',compound)


What I have tried:

I tried it like this:

String[] segments = compound.split("(\([A-Za-z0-9]*\)[0-9]*)");


But I am getting an "illegal escape character" error.
Posted
Updated 21-Oct-21 23:09pm

1 solution

The backslash character in Java strings is an escape character: it introduces a sequence instead of being inserted on it's own: Characters - Learning the Java Language (Numbers and Strings)[^]
To instead a backslash, you double it:
Java
String s = "\\in backslashes\\";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900