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

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -