php - How to extend regex to find multiple matches? -


this current regex (used in parsing ical file):

/(.*?)(?:;(?=(?:[^"]*"[^"]*")*[^"]*$))([\w\w]*)/ 

the current output using preg_match() this:

//output 1 - `preg_match()` array (     [0] => tzid="greenwich mean time:dublin; edinburgh; lisbon; london"     [1] => value=date;rsvp=false;language=en-gb ) 

i extend regex output (i.e. find multiple matches):

//output 2 array (     [0] => tzid="greenwich mean time:dublin; edinburgh; lisbon; london"     [1] => value=date     [2] => rsvp=false     [3] => language=en-gb )     

the regex should search each semicolon not contained within quoted substring , provide match.


cannot swap preg_match_all() gives unwanted output

//output 3 - `preg_match_all()` array (     [0] => array         (             [0] => tzid="greenwich mean time:dublin; edinburgh; lisbon; london";value=date;rsvp=false;language=en-gb         )      [1] => array         (             [0] => tzid="greenwich mean time:dublin; edinburgh; lisbon; london"         )      [2] => array         (             [0] => value=date;rsvp=false;language=en-gb         )  ) 

(.+?)(?:;(?=(?:[^"]*"[^"]*")*[^"]*$)|$) 

try this.see demo.

https://regex101.com/r/pg1ku1/18


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -