Skip to content

Instantly share code, notes, and snippets.

@romulodl
Created December 20, 2011 23:22
Show Gist options
  • Save romulodl/1503775 to your computer and use it in GitHub Desktop.
Save romulodl/1503775 to your computer and use it in GitHub Desktop.
Example of REGEX
<?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