The regular expression can be optimized a little more or mayb...

Recommend this page to a friend!

      AMP Remove unused CSS  >  All threads  >  The regular expression can be...  >  (Un) Subscribe thread alerts  
Subject:The regular expression can be...
Summary:Package rating comment
Messages:2
Author:David M. Miller
Date:2016-05-19 04:56:22
 

 

David M. Miller rated this package as follows:

Utility: Insufficient
Consistency: Insufficient
Documentation: Insufficient

  1. The regular expression can be...   Reply   Report abuse  
Picture of David M. Miller David M. Miller - 2016-05-19 04:56:22
The regular expression can be optimized a little more or maybe he could use a DOM library to parse the content.

  2. Re: The regular expression can be...   Reply   Report abuse  
Picture of Marcel Soler Marcel Soler - 2016-05-19 07:18:01 - In reply to message 1 from David M. Miller
Dom parsing in this case is unnecessary and much slower.

Feel free to propose an improvement of regular expressions.

Here are the expressions most used in the code:


$selectors = array(

'cls'=> array('prefix'=>".",
'regex_css'=>"/\.([a-z][a-z0-9\-_]*)[^a-z0-9\-_]/Usim",
'find_in_html'=>"/<[^>]*\s+class=['\"]\s*(?:([^'\"]+)\b\s*)*['\"]/ism"),

'id'=> array(
'prefix'=>"#",
'regex_css'=>"/#([a-z][a-z0-9\-_]*)[^a-z0-9\-_]/im",
'find_in_html'=>"/<[^>]*\s+id=['\"]([^'\"]+)['\"]/im"),

'tags'=> array(
'prefix'=>"",
'regex_css'=>"/^([^\.#@:][a-z0-9\-_]*)\b/im",
'find_in_html'=>"/<([a-z][^\s><]*)\b/i")

);

 

For more information send a message to info at phpclasses dot org.