java regular expression split pattern -


I want to split the following string:

  string line = "DOB, 1234567890 , 11.07 / 05/12, \ "before, last \", 100, \ ", one, good, boy \" ";   

In the following token:

  DOB 1234567890 11 07/05/12 First, last 100, one, good, boy   

I tried to use the following regular expression:

  import java.util *; Import java.lang *; Import java.util.regex *; Import org.apache.commons.lang.StringUtils; Square split string {public static final string quotes = "\" [[(AG) | (AZ)] + ((az) | (AZ)).) *). (Az) | (AZ))]. \ ""; Public Stable Last String ISSUE_UPLOAD_FILE_PATTERN = "((az) | (AZ)) + [((az) | (AZ)).)) * + (" + Citation + ".,)]. (Az) | (AZ )) + ("+ Citation +") "; Public static zero main (string [] args) {string line = "DOB, 1234567890,11,07 / 05/12, \" first, last \ ", 100, \" is, one, good, boy \ ""; String Delimiter = ","; Pattern p = Pattern.compile (ISSUE_UPLOAD_FILE_PATTERN); Pattern Pattern = Pattern.compile (ISSUE_UPLOAD_FILE_PATTERN); String [] output = pattern. Split (line); System.out.println ("Pattern:" + Pattern); {String A: Output} for {System.out.println ("Output:" + A); }}}   

Do I have anything missing in regular expression? This is an updated version of your code which gives you the expected output:

("[^ \?",]) | \ "([^ \"] *) \ ") (= ($ |,)) "; Public static zero main (string [] args) {string line = "DOB, 1234567890,11,07 / 05/12, \" first, last \ ", 100, \" is, one, good, boy \ ""; Matcher matcher = Pattern.compile (ISSUE_UPLOAD_FILE_PATTERN) .Misher (line); While (matcher.find ()) {if (matcher.group (3)! = Null) {System.out.println (matcher.group (3)); } Else {System.out.println (matcher.group (4)); Regex works like this: (? & Lt; = (^ |,)) : Check that the string before the match is the beginning of the string or ,
([^ [[^ \ ",] +) | \" ([^ \ "] *) \") : match either " / (? = ( $ |,)) Any number ("no") & gt; " or / code>: Check that the post-match letter is the result of string or ,
, the result will be either group 3 or 4, depending on which Matched.

Comments