PHP Velho Oeste 2024

Exemplos

Exemplo #1 Exemplos de Expressões Regulares

<?php
// Retorna true se "abc" existir em qualquer lugar de $string.
ereg ("abc"$string);

// Retorna true se "abc" existir no início de $string.
ereg ("^abc"$string);

// Retorna true se "abc" existir no final de $string.
ereg ("abc$"$string);

// Retorna true se o navegador do cliente  for Netscape 2, 3 ou MSIE 3.
eregi ("(ozilla.[23]|MSIE.3)"$_SERVER["HTTP_USER_AGENT"]);

// Adiciona três palavras separadas por espaço em $regs[1], $regs[2] e $regs[3].
ereg ("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)"$string,$regs);

// Acrescenta a tag <br /> no início de $string.
$string ereg_replace ("^""<br />"$string);

// Acrescenta a tag <br />; no final de $string.
$string ereg_replace ("$""<br />"$string);

// Remove todos caracteres de nova linha (newline) em $string.
$string ereg_replace ("\n"""$string);
?>

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top