note 116197 deleted from function.preg-match-all by salathe

From: Date: Fri, 21 Nov 2014 14:59:35 +0000
Subject: note 116197 deleted from function.preg-match-all by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-200993@lists.php.net to get a copy of this message
Note Submitter: admin at nyancode dot me ---- 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

« previous php.notes (#200993) next »