Advanced query Engine With Regex

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
moallemi
Forum Newbie
Posts: 2
Joined: Wed Oct 15, 2008 11:28 am

Advanced query Engine With Regex

Post by moallemi »

I want to create a query engine that parse an input string and give me a standard array, then i create sql query from that, but i have problem with regex!

can anybody help me?

my input string can be in one of these formats:

Code: Select all

 
//format #1
$string = "keyword1 keyword2 source:src1,src2 with space,src3 category:cat1,cat2";
 
//format #2
$string = "keyword1 keyword2 category:cat1,cat2 source:src1,src2 with space,src3";
 
i want to parse these string and get this array with regex:

Code: Select all

 
Array 
( 
    [keyword] => Array 
        ( 
            [0] => keyword1 
            [1] => keyword2 
        ) 
 
    [source] => Array 
        ( 
            [0] => src1 
            [1] => src2 with space 
            [2] => src2 
        ) 
    [category] => Array 
        ( 
            [0] => cat1 
            [1] => cat2 
        ) 
 
)
 
Post Reply