In this question @middus explained to me how to extract a word / string from a text so i can show the results highlighted.
I have the following function
$regex = '/([A-Za-z0-9.,-]+\s*){0,5}\sconsectetur purus(\s|[,.!?])(\s*[A-Za-z0-9.,-]+){0,5}/';
preg_match($regex, $content, $matches);
echo $matches[0];
consectetur purus is the query string that i inserted in my form. Problem is that in the text sometimes it appears like Consectetur purus.
How can i modify the regex pattern to match the query string i searched either is lowercase or uppercase and return the original text?
You can just use the /i regular expression modifier to allow for case insensitive searching.