Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Regular-expressions/NetRexx/regular-expressions.netrexx
Normal file
37
Task/Regular-expressions/NetRexx/regular-expressions.netrexx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
import java.util.regex.
|
||||
|
||||
st1 = 'Fee, fie, foe, fum, I smell the blood of an Englishman'
|
||||
rx1 = 'f.e.*?'
|
||||
sbx = 'foo'
|
||||
|
||||
rx1ef = '(?i)'rx1 -- use embedded flag expression == Pattern.CASE_INSENSITIVE
|
||||
|
||||
-- using String's matches & replaceAll
|
||||
mcm = (String st1).matches(rx1ef)
|
||||
say 'String "'st1'"' 'matches pattern "'rx1ef'":' Boolean(mcm)
|
||||
say
|
||||
say 'Replace all occurrences of regex pattern "'rx1ef'" with "'sbx'"'
|
||||
stx = Rexx
|
||||
stx = (String st1).replaceAll(rx1ef, sbx)
|
||||
say 'Input string: "'st1'"'
|
||||
say 'Result string: "'stx'"'
|
||||
say
|
||||
|
||||
-- using java.util.regex classes
|
||||
pt1 = Pattern.compile(rx1, Pattern.CASE_INSENSITIVE)
|
||||
mc1 = pt1.matcher(st1)
|
||||
mcm = mc1.matches()
|
||||
say 'String "'st1'"' 'matches pattern "'pt1.toString()'":' Boolean(mcm)
|
||||
mc1 = pt1.matcher(st1)
|
||||
say
|
||||
say 'Replace all occurrences of regex pattern "'rx1'" with "'sbx'"'
|
||||
sx1 = Rexx
|
||||
sx1 = mc1.replaceAll(sbx)
|
||||
say 'Input string: "'st1'"'
|
||||
say 'Result string: "'sx1'"'
|
||||
say
|
||||
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue