fork(4) download
  1. import java.util.regex.*;
  2. import java.util.*;
  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 text = "avcavf 213.123.11.255aoegger";
  11. String octet = "(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)";
  12. Pattern p = Pattern.compile("(?<!\\d)" + octet + "(?:\\." + octet +"){3}(?!\\d)");
  13. Matcher m = p.matcher(text);
  14. System.out.println(m.find() ? m.group() : "Not found");
  15. }
  16. }
Success #stdin #stdout 0.05s 27976KB
stdin
Standard input is empty
stdout
213.123.11.255