Created
March 23, 2018 08:14
Revisions
-
webstory created this gist
Mar 23, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ import java.util.regex.Pattern; import java.util.regex.Matcher; class Main { public static void main(String[] args) { String s = "여기는.어디.입니까-12"; Pattern p = Pattern.compile("^([^.]+\\.[^.]+\\.[^-.]+)(?:-([0-9]{2}))?$"); Matcher m = p.matcher(s); if(m.find()) { String wordonly = m.group(1); String cellNum = m.group(2); System.out.println(wordonly); if(cellNum != null) { System.out.println(cellNum); } else { System.out.println("44"); } } else { System.out.println("Malformed 3word"); } } }