Jump to content

regex for preg_split ?


feha

Recommended Posts

Hi

I do have a problem with extracting into array search input keywords ...

 

I use:

$keywords = preg_split('/[\s,]+/', $keywords);

 

to split input keywords ...

it works o.k. with spaces etc ...

 

I do have a problem with phrase search  ...

 

example:

 

me and "my friends" or you and "your friends"

 

Is split o.k. but i do not want to split the word within quotes ...

 

the word within the quotes should not split in to  "my  ....  friends" this makes problems with MySQL query when searching phrases ...

 

the array:

Array ( [0] => me [1] => and [2] => "my [3] => friends" [4] => or [5] => you [6] => and [7] => "your [8] => friends" )

 

I'm not good in RegEx-es any help would be appreciated ...

 

The expression

'/"(.*?)"/'

can extract the content within double quotes but i can't combine it with preg_split.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.