fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String s = "!\nmap-class frame-relay TempMap_1\n frame-relay cir 1536000\n frame-relay bc 15360\n frame-relay mincir 281000\n frame-relay adaptive-shaping becn\n service-policy output AB_TEMP_F1536K_0-256K-384K-128K_18\nlogging trap debugging\nlogging source-interface Loopback1\nlogging 136.91.111.21";
  11. Pattern p = Pattern.compile("map-class frame-relay TempMap_1.*(?:\\R\\h+.*)*");
  12. Matcher m = p.matcher(s);
  13. List<String> res = new ArrayList<>();
  14. while(m.find()) {
  15. res.add(m.group());
  16. }
  17. System.out.println(res);
  18. }
  19. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
[map-class frame-relay TempMap_1
 frame-relay cir 1536000
 frame-relay bc 15360
 frame-relay mincir 281000
 frame-relay adaptive-shaping becn
 service-policy output AB_TEMP_F1536K_0-256K-384K-128K_18]