php - preg match all with static string at beginning of pattern -


i putting preg match in php following string:

{{beginning_of_string|:|optional_param|:|http_link}}  {{beginning_of_string|:|optional_param|:|text}}  {{beginning_of_string}} 

all 3 of these possibilities can occur in overall string, or single occurrence. here regex far:

preg_match_all('#\{\{beginning_of_string(.+?)\}\}#', $content, $string) 

so far matches first 2 occurrences of string, , not last one. regex matches last occurrence:

#\{\{beginning_of_string\}\}# 

i'm new regex know simple. have thoughts? in advance.

+ means "one or more repetitions".

you need * "zero or more repetitions":

preg_match_all('#\{\{beginning_of_string(.*?)\}\}#', $content, $string) 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -