PHP Regular expression, how to match the first section which includes a [ symbol?

Mirageboss

New Member
Hi Guys ive tried to search for this answer all morning, but with no luck, all i want to do is match [slideshow or [gallery with the included [ bracket..code as follows.\[code\]$gallery = get_post_meta($post->ID, 'gallery', true);if (preg_match("|^/[slideshow", $gallery)) { echo "Slideshow was forund";} else if (preg_match("|^/[nggallery", $gallery)) { echo "Gallery was found";} else { echo "No Match found - No Meta Data available"; }\[/code\]The regular expression ive used, i though would work like this.search the start of the string, and using / would escape the [ from being used as part of the regular expression and be part of the search, regular expressions is just not my thing....although the more reading i do, it becomes a little more clearer..thanks
 
Back
Top