Im trying to parse a string thats like this;
/^/^this is a big|/*this is a bold text|/-this is strike through| i need the text between $/^ and $|
Tested the regex at regexr and java regex tester and both of them shows its working.
Also referenced to: Java regex matcher always returns false and Regex that always returns false
Compared my code with Java Regex tutorial on Jenkov and it seems to be simillar
My Code
public static final String bold = "/\\/\\*(.*?)\\|/g";
public static final String strike = "/\\/\\-(.*?)\\|/g";
public static final String big = "/\\/\\^(.*?)\\|/g";
String input = "/^/^this is a big|/*this is a bold text|/-this is strike through|";
SpannableStringBuilder str = new SpannableStringBuilder(input.trim());
Pattern pattern = big;
Matcher matcher = pattern.matcher(str.toString());
while (matcher.find()) {
str.setSpan(new RelativeSizeSpan((1.25f)),
matcher.start(), matcher.end(),
SPAN_INCLUSIVE_INCLUSIVE);
//input.replace(matcher.group(1),"");
}
so matcher.find() returns false and there arent any matcher.groups() either.
I really have no idea where i am slipping up here.
EDIT
Pattern pattern = Pattern.compile(big);
I forgot to add that part since the regex itself was a return from another function which returns an already compiled pattern. Thanks for all of your help.
Stringto aPatternwhich won't even compile. Also in Java, you don't need to have/in regex like it is in other languages like JavaScript.