Regular expressions: Difference between revisions

no edit summary
(Adding MUMPS example)
No edit summary
Line 67:
Dalmatians: +100 +2
Gives 101 dogs
</pre>
 
=={{header|Argile}}==
<lang Argile>use std, regex
 
(: matching :)
if "some matchable string" =~ /^some" "+[a-z]*" "+string$/
echo string matches
else
echo string "doesn't" match
 
(: replacing :)
let t = strdup "some allocated string"
t =~ s/a/"4"/g
t =~ s/e/"3"/g
t =~ s/i/"1"/g
t =~ s/o/"0"/g
t =~ s/s/$/g
print t
free t
 
(: flushing regex allocations :)
uninit regex
 
check mem leak; use dbg (:optional:)</lang>
 
(note that it needs to be compiled with argrt library)
 
Output:
<pre>
string matches
$0m3 4ll0c4t3d $tr1ng
</pre>
 
Anonymous user