ok so i am pulling my hair out here trying to figure out why php doesnt want to work right with this reg expression

what i am looking for


what i have
preg_match_all('\{blog:[A-Za-z0-9_]+\}', $replaced_content, $matches, PREG_SET_ORDER);

this is the error it is out putting

Warning: preg_match_all() [function.preg-match-all]: Delimiter must not be alphanumeric or backslash in

where i tested it

please help. ive started to understand reg expressions more but this error just does make sense to me

thanks in advance

Recommended Answers

All 7 Replies

thank you about that !

Try this.

	$replaced_content = " abcs is here {blog:vibhadevit} mnop dsgdh 3535 {blog:computer} after blog content";
	preg_match_all('/{blog:[A-Za-z0-9_]+}/', $replaced_content, $matches, PREG_SET_ORDER);
	echo '<pre>';

@viraaa: huh?

Interesting why is it that you use the / after the }?

Another thing is what if I wanted to do something like this {blog:name_of_blog/tag:tag_name} and later on I could grab one or both, if both exist, for later. The example is is to put them into variables I would guess.

Interesting why is it that you use the / after the }?

The / before and after is called the delimiter, which was missing in your regex. The delimiter can be any character you want, as long as the regex starts and ends with it. The reason for having one, is that you can put additional options after the closing delimiter (case sensitivity for example).

Thanks pritaeas for info.

thanks thats good to know. btw i was able to find a work around for the variables i was talking about.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.