vendredi 3 novembre 2017

Java Regex - Included array

I'm stuck with a javax regex.

I have this kind of string :

 " [[[10,10],[20,20],[30,30]], [[11,11],[21,21],[31,31]]] "

The goal is to split this string into different levels of arrays. If I'm not clear this is what I should get after the treatment.

  1. Split the string into the first level:

    " [[[10,10],[20,20],[30,30]], [[11,11],[21,21],[31,31]]] "
    
    

    Give

       "  [[10,10],[20,20],[30,30]], [[11,11],[21,21],[31,31]] "
    
    
  2. Split each result of 1. into the second level:

      " [[10,10],[20,20],[30,30]], [[11,11],[21,21],[31,31]]  "
    
    

    Give

      "  [[10,10],[20,20],[30,30]] "
        and
      "  [[11,11],[21,21],[31,31]] "
    
    
  3. Split each result of 2. into the third level

      " [[10,10],[20,20],[30,30]]  "
    
    

    Give

      "  [10,10] "
        and
      "  [20,20] "
        and 
      "  [30,30] "
    
    

    And

      " [[11,11],[21,21],[31,31]]  "
    
    

    Give

      "  [11,11] "
        and
      "  [21,21] "
        and 
      "  [31,31] "
    
    

So if you have the good regex pattern to do that, it will be nice.

Thanks in advance, PKB

Aucun commentaire:

Enregistrer un commentaire