note 116197 added to function.preg-match-all

From: Date: Thu, 20 Nov 2014 16:40:15 +0000
Subject: note 116197 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-200965@lists.php.net to get a copy of this message
preg_match is good but it's slower than strpos in case that you just need to check if a string occurs. So instead of using regular expression you can simply use: <?php if(strpos('This is a text', 'a') !== FALSE){ echo 'String found'; }else{ echo 'String not found'; } ?> You can use regular expression in complex case and for that a live regex testing tool is needed. Liveregex.com is one of good tools out there which help you to test and demonstrate PHP regex, you can create a permalink to share your regex too. Here's an example http://liveregex.com/0gvKo ---- Server IP: 72.52.91.14 Probable Submitter: 116.100.136.121 ---- Manual Page -- http://php.net/manual/en/function.preg-match-all.php Edit -- https://master.php.net/note/edit/116197 Del: integrated -- https://master.php.net/note/delete/116197/integrated Del: useless -- https://master.php.net/note/delete/116197/useless Del: bad code -- https://master.php.net/note/delete/116197/bad+code Del: spam -- https://master.php.net/note/delete/116197/spam Del: non-english -- https://master.php.net/note/delete/116197/non-english Del: in docs -- https://master.php.net/note/delete/116197/in+docs Del: other reasons-- https://master.php.net/note/delete/116197 Reject -- https://master.php.net/note/reject/116197 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200965) next »