Filtering post title using regex
-
Hi all,
I am trying to grab text between some quotes in a title tag and I’m using regex to do this. I have the following code to do this.
$subject = ‘Hello – “My Name Is Eric”‘ //post title
$pattern =’/”((?:[^\\”]|\\”)*)”/’;preg_match($pattern, $subject, $matches );
echo “the match is $matches[0]”;it works perfect. It returns “My Name Is Eric”
However if I replace $subject variable with the following:
$subject = the_title(“”,””,FALSE); //post title
there is no match.
I just can’t figure out why the_title() which returns the exact same text, Hello – “My Name Is Eric” doesn’t work. Can anyone help?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Filtering post title using regex’ is closed to new replies.