Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. .{0,}([.{0,}])1{0,} (.{0,})?(.{0,})
  2.  
  3. System.out.println("[NChatBot] Processing chat line: " + msg);
  4. Matcher _m = _namePattern.matcher(msg);
  5. boolean found = false;
  6. while (_m.find()) {
  7. found = true;
  8. System.out.println("1: " + _m.group(1));
  9. System.out.println("2: " + _m.group(2));
  10. System.out.println("3: " + _m.group(3));
  11. }
  12. if (!found) {
  13. System.out.println("Can't parse!");
  14. }
  15.  
  16. String msg = "? ??? [Префикс] Имя ? Сообщение";
  17. Pattern _namePattern = Pattern.compile("(\[[^\]\[]*])\s+(.*?)\s*\?\s*(.*)");
  18. Matcher _m = _namePattern.matcher(msg);
  19. boolean found = false;
  20. while(_m.find()) {
  21. found = true;
  22. System.out.println("1: "+_m.group(1));
  23. System.out.println("2: "+_m.group(2));
  24. System.out.println("3: "+_m.group(3));
  25. }
  26. if(!found) {
  27. System.out.println("Can't parse!");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement