Anonymous user
Regular expressions: Difference between revisions
→{{header|PHP}}
({{omit from|PARI/GP}}) |
|||
Line 626:
=={{header|PHP}}==
{{works with|PHP|5.2.0}}
<lang php>
# Test▼
▲Test
▲<lang php>if (preg_match('/string$/', $string))
{
echo "Ends with 'string'\n";
}
# Replace▼
echo "Found 'a' and replace it with 'another', resulting in this string: $string\n";</lang>▼
Output:
▲Replace
<pre>Ends with 'string'
Foud 'a' and replaced it with 'another', resulting in this string: I am another string</pre>
▲<lang php>$string = preg_replace('/\ba\b/', 'another', $string);
▲echo "Found 'a' and replace it with 'another', resulting in this string: $string\n";</lang>
=={{header|PicoLisp}}==
|