Forum Moderators: coopster

Message Too Old, No Replies

Regular expression

         

stilmark

10:43 pm on Jul 24, 2006 (gmt 0)

10+ Year Member



I'm trying to use reg.exp. to isolate part of a query. Example query:

"domain:mydomain.com other query"

I would like to isolate the part "mydomain.com", excluding the trailing "other query". Ideally this should work even if the query is structure like this:

"other query domain:mydomain.com"

This is as far as I've gotten (copying from other scripts). If there is a better - more elegant - way to do this I am all ears.

$pattern = "`domain:([a-z0-9_.-])`sieU";
$replacement = "'$1'";

$domain = preg_replace($pattern, $replacement, $query);

Could someone also explain what the "sieU" in the pattern does?

Thanks in advance.

[edited by: coopster at 10:57 pm (utc) on July 24, 2006]

coopster

10:58 pm on Jul 24, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, stilmark.

The PHP manual page has a fairly detailed explanation of the Pattern Modifiers [php.net]. If any of them don't make sense, just let us know and we'll see if we can't clear things up for you.