So I wrote a little section of code in a program of mine that uses the split method to parse out and sort the individual components held within a string. Below is a sample of the code:
String[] sArray;
String delimiter = "*";
String test = "TEXT*TEXT*TEXT*";
String a = "";
String b = "";
String c = "";
sArray= test.split(delimiter);
a = sArray[0];
b = sArray[1];
c = sArray[2];
System.out.println("A is: " + a + "\nB is: " + b + "\nC is: " + c);
However, when I run this program, it returns an error stating that:
Dangling meta character '*' near index 0
So I googled this error and found it might be related to an issue with how *
can be considered a wildcard character in regex. So I tried:
String delimiter = "\*"
But that just returned another error stating:
illegal escape character
Has anyone ran into this issue before or know how you are (if you are) supposed to escape *
in java?