public class StringMerger {
public static boolean isMerge(String s, String part1, String part2) {
for (int i = 0; i < part1.length(); i++)
{
s = s.replaceAll(part1.substring(i, i+1) , "");
}
for (int a =0; a < part2.length(); a++)
{
s = s.replaceAll(part2.substring(a , a+1) , "");
}
return (s.length() == 0);
}
}
I am trying to see if the two Strings given part1 and part2 can combine to create the given String s
.
This works for most regular cases.
However, under the category special cases I keep receiving an error:
Dangling meta character `+` near index 0
It is not always just +
, sometimes it will *
or ?
.
What is a dangling meta character and is there any way for me to correct this in the given code.