regular expression — PHP

commandline session

<?php
$text = “Hello World”;
if ( preg_match( “/r.*?d/”, $text, $array ) ) {
print “<pre>n”;
print_r( $array );
print “</pre>n”;
}
?>

note: preg_match — Perform a regular expression match
source : http://www.phpcode.net

OUTPUT

$ 4.2.36 13 513—> php rep.php
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20100525/suhosin.so’ – /usr/lib/php5/20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0
<pre>
Array
(
[0] => rld
)
</pre>
$ 4.2.36 14 514—>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s