Created
December 20, 2011 23:22
-
-
Save romulodl/1503775 to your computer and use it in GitHub Desktop.
Example of REGEX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//pega tudo que tem oi ou ola = (oi|ola) | |
$pattern = "/(oi|ola)/"; | |
//para evitar que palavras derivadas de oi ou ola (ex: foi, escola) sejam capturadas, colocamos \b antes e depois um \W, um "no word" (caractere que não seja uma letra, ex: espaço, vírgula). | |
$pattern = "/\b(oi|ola)\W/"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment