Regular expressions: Difference between revisions

Content added Content deleted
(Add Genie)
Line 756: Line 756:
print "matched '%s' in '%s'", re.get_pattern(), sentence
print "matched '%s' in '%s'", re.get_pattern(), sentence


print "replace with 'another': %s", re.replace(sentence, sentence.length, 0, "another")
print("replace with 'different': %s",
re.replace(sentence, sentence.length, 0, "different"))


except err:RegexError
except err:RegexError
Line 765: Line 766:
prompt$ ./regularExpressions
prompt$ ./regularExpressions
matched 's[ai]mple' in 'This is a sample sentence.'
matched 's[ai]mple' in 'This is a sample sentence.'
replace with 'another': This is a another sentence.</pre>
replace with 'different': This is a different sentence.</pre>


=={{header|Go}}==
=={{header|Go}}==