Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1.  
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. String myString = "1+(2-(2+3)*4/(3+1))*5";
  10. findStuff(myString);
  11.  
  12.  
  13. }
  14.  
  15.  
  16. public static void findStuff(String str) {
  17. String pattern = "\\((.+)\\)";
  18.  
  19. Pattern p = Pattern.compile(pattern);
  20. Matcher m = p.matcher(str);
  21. while (m.find()) {
  22. String sub = m.group(1);
  23. System.out.println(" Word: " + sub);
  24.  
  25. findStuff(sub);
  26. }
  27.  
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement