Skip to content

Instantly share code, notes, and snippets.

@sumanssaurabh
Forked from rkcb/javacommon.md
Created March 31, 2019 22:49
Show Gist options
  • Save sumanssaurabh/3bd081b18a3faa51c4267b50a55de34b to your computer and use it in GitHub Desktop.
Save sumanssaurabh/3bd081b18a3faa51c4267b50a55de34b to your computer and use it in GitHub Desktop.
Java common

Java common

Strings

Find a substring by a regular expression:

  String pattern = "(.*)(\\d\\d\\d\\d)(.*)";
  String line = "2018-11-22 00:00:00";
  Pattern re = Pattern.compile(pattern);
  Matcher matcher = re.matcher(line);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment