Advertisement
Anzak

get property from string

Jan 4th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1.     Pattern color = Pattern.compile("(?i).*BACKGROUND=(\\d+),(\\d+),(\\d+).*");
  2.     Matcher m = color.matcher("bla-bla-bla background=100,150,200 FONT=bold");
  3.     int r = 255, g = 255, b =255;
  4.     if ((m.find() && m.groupCount() == 3)) {
  5.       r = NumberFunctions.findInteger(m.group(1), 255);
  6.       g = NumberFunctions.findInteger(m.group(2), 255);
  7.       b = NumberFunctions.findInteger(m.group(3), 255);
  8.     }
  9.     Color background = new Color(r,g,b);
  10.  
  11.     System.out.println(r + "," + g + "," + b);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement