fork download
  1. <?php
  2. $matches = null;
  3. $matchCount = preg_match_all(
  4. '/\G\s*+((\((?:\s*+(?2)\s*+(?(?!\)),)|\s*+[^()\',\s]++\s*+(?(?!\)),)|\s*+\'[^\'\r\n]*+\'\s*+(?(?!\)),))++\))|[^()\',\s]++|\'[^\'\r\n]*+\')\s*+(?:,|$)/',
  5. 'AAA , BBB , (CCC , DDD) , \'EEE\', \'FFF,GGG\', (\'HHH\',\'III\'), ( ( \'JJJ\', \'KKK\') , LLL , ( MMM , NNN) ) , OOO , (\'ABC\', \'SDF,SDF()SDF\', ( SDF, SDF ) ,SDF),(sdf,sdf,sdf,sd,(f,f,f,(fsd),\'sdf\')),sdf,\'sdfs\',(Sdf,\'sdfsdf\',(ssdf,\'sdf,sdfsdf)\')) ',
  6. $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
  7. print_r($matches)
  8. ?>
Success #stdin #stdout 0.02s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [0] => AAA  ,
                    [1] => 0
                )

            [1] => Array
                (
                    [0] =>  BBB  ,
                    [1] => 6
                )

            [2] => Array
                (
                    [0] =>  (CCC   ,  DDD)  ,
                    [1] => 13
                )

            [3] => Array
                (
                    [0] =>  'EEE',
                    [1] => 31
                )

            [4] => Array
                (
                    [0] =>  'FFF,GGG',
                    [1] => 38
                )

            [5] => Array
                (
                    [0] =>  ('HHH','III'),
                    [1] => 49
                )

            [6] => Array
                (
                    [0] =>  (  ( 'JJJ',  'KKK')  , LLL  , (   MMM  ,  NNN) ) ,
                    [1] => 64
                )

            [7] => Array
                (
                    [0] =>  OOO ,
                    [1] => 115
                )

            [8] => Array
                (
                    [0] =>  ('ABC', 'SDF,SDF()SDF',  (  SDF,  SDF  )  ,SDF),
                    [1] => 121
                )

            [9] => Array
                (
                    [0] => (sdf,sdf,sdf,sd,(f,f,f,(fsd),'sdf')),
                    [1] => 170
                )

            [10] => Array
                (
                    [0] => sdf,
                    [1] => 207
                )

            [11] => Array
                (
                    [0] => 'sdfs',
                    [1] => 211
                )

            [12] => Array
                (
                    [0] => (Sdf,'sdfsdf',(ssdf,'sdf,sdfsdf)'))  
                    [1] => 218
                )

        )

    [1] => Array
        (
            [0] => Array
                (
                    [0] => AAA
                    [1] => 0
                )

            [1] => Array
                (
                    [0] => BBB
                    [1] => 7
                )

            [2] => Array
                (
                    [0] => (CCC   ,  DDD)
                    [1] => 14
                )

            [3] => Array
                (
                    [0] => 'EEE'
                    [1] => 32
                )

            [4] => Array
                (
                    [0] => 'FFF,GGG'
                    [1] => 39
                )

            [5] => Array
                (
                    [0] => ('HHH','III')
                    [1] => 50
                )

            [6] => Array
                (
                    [0] => (  ( 'JJJ',  'KKK')  , LLL  , (   MMM  ,  NNN) )
                    [1] => 65
                )

            [7] => Array
                (
                    [0] => OOO
                    [1] => 116
                )

            [8] => Array
                (
                    [0] => ('ABC', 'SDF,SDF()SDF',  (  SDF,  SDF  )  ,SDF)
                    [1] => 122
                )

            [9] => Array
                (
                    [0] => (sdf,sdf,sdf,sd,(f,f,f,(fsd),'sdf'))
                    [1] => 170
                )

            [10] => Array
                (
                    [0] => sdf
                    [1] => 207
                )

            [11] => Array
                (
                    [0] => 'sdfs'
                    [1] => 211
                )

            [12] => Array
                (
                    [0] => (Sdf,'sdfsdf',(ssdf,'sdf,sdfsdf)'))
                    [1] => 218
                )

        )

    [2] => Array
        (
            [0] => 
            [1] => 
            [2] => Array
                (
                    [0] => (CCC   ,  DDD)
                    [1] => 14
                )

            [3] => 
            [4] => 
            [5] => Array
                (
                    [0] => ('HHH','III')
                    [1] => 50
                )

            [6] => Array
                (
                    [0] => (  ( 'JJJ',  'KKK')  , LLL  , (   MMM  ,  NNN) )
                    [1] => 65
                )

            [7] => 
            [8] => Array
                (
                    [0] => ('ABC', 'SDF,SDF()SDF',  (  SDF,  SDF  )  ,SDF)
                    [1] => 122
                )

            [9] => Array
                (
                    [0] => (sdf,sdf,sdf,sd,(f,f,f,(fsd),'sdf'))
                    [1] => 170
                )

            [10] => 
            [11] => 
            [12] => Array
                (
                    [0] => (Sdf,'sdfsdf',(ssdf,'sdf,sdfsdf)'))
                    [1] => 218
                )

        )

)