Re: About Preg Match patterns
| From: | Daniel Brown | Date: | Wed, 01 Aug 2012 19:02:33 +0000 |
| Subject: | Re: About Preg Match patterns | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318611@lists.php.net to get a copy of this message | ||
On Thu, Aug 2, 2012 at 12:49 AM, Tolga <kacmaztolga@gmail.com> wrote:
> hi, i have a question, i dont know what keywords to search, so im asking
> here.
>
> while using preg_match, there are lots of thing that can be written as
> $pattern.
> for example:
> preg_match("/php/i", "PHP is the web scripting language of choice.")
>
> what is the meaning of /i ?
The /x character switch is called a regexp modifier. In this
case, /i is for cAsE-iNsEnSiTiViTy.
> or '@^(?:http://)?([^/]+)@i' there are lots of chars
> here,
To match a URL, insensitively, whether or not it contains http://.
In this case, @ is used as the separator because of the slashes in
the protocol and path.
> or this: /(?P<name>\w+): (?P<digit>\d+)/
> /[^\\d\\sa-zA-Z$_]/
> /^[a-zA-Z\p{Cyrillic}0-9\s\-]+$/u (there is a extra "/u" )
>
> #^http:\/\/(.*)\.(gif|png|jpg)$#i
> #<head>(.*?)<\/head>#si
>
> there is lots and lots of different usage of these.
>
> my question is, where can i find a very detailed information about these ? i
> want and need to know whats what about these.
I'd recommend http://regular-expressions.info/, which is a really
handy site for regexp reference by users of all skill levels.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/