php - How to make part of regex pattern optional? -


im working regex pattern:

|img_class.*?<img src="(.*?)"(.*?)<\/td>|ms 

but want make <img src="(.*?)" optional (not src part), because img_class td empty , when pattern fails.

i tried |img_class.*?(<img src="(.*?)")?(.*?)<\/td>|ms never match.

(i know use xpath or better im using pretty big class , dont want recode right now).

|img_class.*?(?:<img src="(.*?)")?(.*?)<\/td>|ms 

Comments

Popular posts from this blog

delphi - TJvHidDeviceController "DevicePath" always showing "\" -

Disabling Android home button for industry application -

asp.net mvc 3 - Unexpected "foreach" keyword after "@" character -