Unknown modifier ” error preg_match

Unknown modifier ” error preg_match

Running this error while adopting preg_mathc in php? Just check if the delimiters are not used in your string – mostly this would fix the problem.

$example = "<root><tag1>content1</tag1></root>";
$pattern = "/<tag1>.+</tag1>/";
preg_match($pattern, $example, $matches) ; 

If you run the above snippet, you would run the error as the delimiter ‘/’ is the part of the string – so changing the delimiter, say, to ‘?’ would solve the problem. like

 $pattern = "?<tag1>.+</tag1>?

Hope it would help.

See how you would solve these known algorithm problems

Java solution for checking anagram strings – tell if phrases are anagrams

Implementing tokenizer and adding tokens to the linked list

Array reversal in Recurrsion

Find the pairs that makes K Complementary in the given array java solution

Check if two strings are anagrams or not

Flatten nested javascript array

binary tree problems with solution

String Ordered Permutation Algorithm Problem

find longest word in the sentence

Kadane’s algorithm in C – Dynamic Programming

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*