fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5. import java.io.*;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String string = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \n\nName Group 12345678 \nALEX A ALEX \nID# PUBLIC NETWORK \nXYZ123456789 \n\n\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.\n";
  12. Matcher m = Pattern.compile("(?m)^(.*)ID#.*([\\s\\S]*)").matcher(string);
  13. if (m.find()) {
  14. Matcher m1 = Pattern.compile("(?m)^.{" + m.group(1).length() + "}(?<!\\S)\\h{0,3}(\\S+)").matcher(m.group(2));
  15. if (m1.find())
  16. System.out.println(m1.group(1));
  17. }
  18. }
  19. }
Success #stdin #stdout 0.1s 27992KB
stdin
Standard input is empty
stdout
XYZ123456789