Regular expressions: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added a link to the CHANGESTR.REX subroutine. -- ~~~~) |
m (→{{header|NetRexx}}: Correct a spelling error.) |
||
Line 897: | Line 897: | ||
say 'String "'st1'"' 'matches pattern "'rx1ef'":' Boolean(mcm) |
say 'String "'st1'"' 'matches pattern "'rx1ef'":' Boolean(mcm) |
||
say |
say |
||
say 'Replace all |
say 'Replace all occurrences of regex pattern "'rx1ef'" with "'sbx'"' |
||
stx = Rexx |
stx = Rexx |
||
stx = (String st1).replaceAll(rx1ef, sbx) |
stx = (String st1).replaceAll(rx1ef, sbx) |
||
Line 911: | Line 911: | ||
mc1 = pt1.matcher(st1) |
mc1 = pt1.matcher(st1) |
||
say |
say |
||
say 'Replace all |
say 'Replace all occurrences of regex pattern "'rx1'" with "'sbx'"' |
||
sx1 = Rexx |
sx1 = Rexx |
||
sx1 = mc1.replaceAll(sbx) |
sx1 = mc1.replaceAll(sbx) |
||
Line 924: | Line 924: | ||
String "Fee, fie, foe, fum, I smell the blood of an Englishman" matches pattern "(?i)f.e.*?": true |
String "Fee, fie, foe, fum, I smell the blood of an Englishman" matches pattern "(?i)f.e.*?": true |
||
Replace all |
Replace all occurrences of regex pattern "(?i)f.e.*?" with "foo" |
||
Input string: "Fee, fie, foe, fum, I smell the blood of an Englishman" |
Input string: "Fee, fie, foe, fum, I smell the blood of an Englishman" |
||
Result string: "foo, foo, foo, fum, I smell the blood of an Englishman" |
Result string: "foo, foo, foo, fum, I smell the blood of an Englishman" |
||
Line 930: | Line 930: | ||
String "Fee, fie, foe, fum, I smell the blood of an Englishman" matches pattern "f.e.*?": true |
String "Fee, fie, foe, fum, I smell the blood of an Englishman" matches pattern "f.e.*?": true |
||
Replace all |
Replace all occurrences of regex pattern "f.e.*?" with "foo" |
||
Input string: "Fee, fie, foe, fum, I smell the blood of an Englishman" |
Input string: "Fee, fie, foe, fum, I smell the blood of an Englishman" |
||
Result string: "foo, foo, foo, fum, I smell the blood of an Englishman" |
Result string: "foo, foo, foo, fum, I smell the blood of an Englishman" |