original_string: private function getSegments($name)
      {
          if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
              $segments = [$m['base']];
              while (!empty($m['extra'])) {
                  $extra = $m['extra'];
                  if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $extra, $m)) {
                      $segments[] = $m['segment'];
                  } else {
                      $segments[] = $extra;
                  }
              }
  
              return $segments;
          }
  
          return [$name];
      }
code: private function getSegments($name)
      {
          if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
              $segments = [$m['base']];
              while (!empty($m['extra'])) {
                  $extra = $m['extra'];
                  if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $extra, $m)) {
                      $segments[] = $m['segment'];
                  } else {
                      $segments[] = $extra;
                  }
              }
  
              return $segments;
          }
  
          return [$name];
      }
code_tokens: private function getSegments ( $ name ) { if ( preg_match ( '/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/' , $ name , $ m ) ) { $ segments = [ $ m [ 'base' ] ] ; while ( ! empty ( $ m [ 'extra' ] ) ) { $ extra = $ m [ 'extra' ] ; if ( preg_match ( '/^\[(?P<segment>.*?)\](?P<extra>.*)$/' , $ extra , $ m ) ) { $ segments [ ] = $ m [ 'segment' ] ; } else { $ segments [ ] = $ extra ; } } return $ segments ; } return [ $ name ] ; }
docstring: Splits a field name into segments as a web browser would do.
  
  getSegments('base[foo][3][]') = ['base', 'foo, '3', ''];
  
  @param string $name The name of the field
  
  @return string[] The list of segments
docstring_tokens: Splits a field name into segments as a web browser would do .