Regular expressions: Difference between revisions
Content added Content deleted
(Added AppleScript version) |
No edit summary |
||
Line 79: | Line 79: | ||
$string =~ s/i/u/ig; # would change "I am a string" into "u am a strung" |
$string =~ s/i/u/ig; # would change "I am a string" into "u am a strung" |
||
==[[PHP]]== |
|||
[[Category:PHP]] |
|||
$string = 'I am a string'; |
|||
Test |
|||
if (preg_match('/string$/', $string)) |
|||
{ |
|||
echo "Ends with 'string'\n"; |
|||
} |
|||
Replace |
|||
$string = preg_replace('/\ba\b/', 'another', $string); |
|||
echo "Found 'a' and replace it with 'another', resulting in this string: $string\n"; |
|||
==[[Ruby]]== |
==[[Ruby]]== |