Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .{0,}([.{0,}])1{0,} (.{0,})?(.{0,})
- System.out.println("[NChatBot] Processing chat line: " + msg);
- Matcher _m = _namePattern.matcher(msg);
- boolean found = false;
- while (_m.find()) {
- found = true;
- System.out.println("1: " + _m.group(1));
- System.out.println("2: " + _m.group(2));
- System.out.println("3: " + _m.group(3));
- }
- if (!found) {
- System.out.println("Can't parse!");
- }
- String msg = "? ??? [Префикс] Имя ? Сообщение";
- Pattern _namePattern = Pattern.compile("(\[[^\]\[]*])\s+(.*?)\s*\?\s*(.*)");
- Matcher _m = _namePattern.matcher(msg);
- boolean found = false;
- while(_m.find()) {
- found = true;
- System.out.println("1: "+_m.group(1));
- System.out.println("2: "+_m.group(2));
- System.out.println("3: "+_m.group(3));
- }
- if(!found) {
- System.out.println("Can't parse!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement