Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
regex with %
import java.util.*; import java.lang.*; import java.util.regex.Matcher; import java.util.regex.Pattern; class Rextester { public static void main(String args[]) { final String input = "%ABC%\n" + "%ABC%-%RED%\n" + "Lorem ipsum %GeT% sit amet, %% consectetur %QW23% elit."; final Pattern pattern = Pattern.compile("(?<!%)(%)(\\w+)(%)(?!%)"); final Matcher matcher = pattern.matcher(input); while (matcher.find()) { System.out.println("["+ matcher.group(0) + "] " + matcher.group(1) + " | " + matcher.group(2) + " | " + matcher.group(3) ); } } }
run
|
edit
|
history
|
help
0
Meena
names
Series_4_8
Selection Sort
JAVA regex for only allow numbers
ContainsMethod
Rotate matrix clockwise
Date_From_Str
4c
Ab