fork(1) download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String formula = "BMI = ( Weight / ( Height * Height ) ) * 703";
  9. String pattern = "(?:^|(?<=[=+\\-*/()]))\\s*([a-z]+)\\s*(?:$|(?=[=+\\-*/()]))";
  10. Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
  11. Matcher m = p.matcher(formula);
  12. while(m.find()) {
  13. System.out.println(m.group(1));
  14. }
  15. }
  16. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout