note 69759 added to reference.pcre.pattern.syntax

From: Date: Tue, 19 Sep 2006 21:12:03 +0000
Subject: note 69759 added to reference.pcre.pattern.syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-117331@lists.php.net to get a copy of this message
Only a small correction to this regexp: %"(.+)"[\s]+((http|https|ftp|file)://[^\s]+?)(.*)%sU It's not necessary to write character class "[..]" if it only contains one character match. Instead of "[\s]+" you can write simply "\s+". The similar is for the character class "[^\s]+", which may be written as "\S+". The "\S" assertion matches all characters, that are NOT whitespace. After those corrections we get a little shorter and easier to read regexp [if we can say that ANY regexp is easy to read at all ;-D ]: %"(.+)"\s+((http|https|ftp|file)://\S+?)(.*)%sU The only miserable thing with this regexp is that it matches patterns like: "Some description" http://www.somepage.com/catalog/file.html but doesn't match links like this one: "Some description" www.somepage.com/catalog/file.html ---- Server IP: 195.136.184.34 Probable Submitter: 83.30.119.149 ---- Manual Page -- http://www.php.net/manual/en/reference.pcre.pattern.syntax.php Edit -- https://master.php.net/note/edit/69759 Del: integrated -- https://master.php.net/note/delete/69759/integrated Del: useless -- https://master.php.net/note/delete/69759/useless Del: bad code -- https://master.php.net/note/delete/69759/bad+code Del: spam -- https://master.php.net/note/delete/69759/spam Del: non-english -- https://master.php.net/note/delete/69759/non-english Del: in docs -- https://master.php.net/note/delete/69759/in+docs Del: other reasons-- https://master.php.net/note/delete/69759 Reject -- https://master.php.net/note/reject/69759 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117331) next »