Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

preg_match pattern for 1 to 3 arguments

Status
Not open for further replies.

elck

Programmer
Apr 19, 2004
176
NL
Hi there,

I have $pattern='/\*pag:([^\]]*):([^\]]*):([^\]]*)\*/';
that works well for three arguments like:

*pag:first:second:third*

But I would like one that works also for fewer arguments, and simple returns an empty string for the patterns missing.

so other patters could be:

*pag:first:second*

and even

*pag:first::third*

can this be done with one pattern?
 
see if this works
Code:
$pattern='/\*pag:([^\]]*?):([^\]]*?):?([^\]]*?)\*/';
 
Mh no, doesn't do the trick,
anyway I programmed my way around the problem,
so thanks anyway.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top