tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
15
Task/Regular-expressions/REXX/regular-expressions-1.rexx
Normal file
15
Task/Regular-expressions/REXX/regular-expressions-1.rexx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/*REXX program demonstrates testing (modeled after Perl example).*/
|
||||
$string = "I am a string"
|
||||
say 'The string is:' $string
|
||||
x = "string"
|
||||
if right($string,length(x))=x then say 'It ends with:' x
|
||||
|
||||
y = "You"
|
||||
if left($string,length(y))\=y then say 'It does not start with:' y
|
||||
|
||||
z = "ring"
|
||||
if pos(z,$string)\==0 then say 'It contains the string:' z
|
||||
|
||||
z = "ring"
|
||||
if wordpos(z,$string)==0 then say 'It does not contain the word:' z
|
||||
/*stick a fork in it, we're done.*/
|
||||
10
Task/Regular-expressions/REXX/regular-expressions-2.rexx
Normal file
10
Task/Regular-expressions/REXX/regular-expressions-2.rexx
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/*REXX program demonstrates substitution (modeled after Perl example).*/
|
||||
$string = "I am a string"
|
||||
old = " a "
|
||||
new = " another "
|
||||
say 'The original string is:' $string
|
||||
say 'old word is:' old
|
||||
say 'new word is:' new
|
||||
$string = changestr(old,$string,new)
|
||||
say 'The changed string is:' $string
|
||||
/*stick a fork in it, we're done.*/
|
||||
11
Task/Regular-expressions/REXX/regular-expressions-3.rexx
Normal file
11
Task/Regular-expressions/REXX/regular-expressions-3.rexx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*REXX program shows non-destructive sub. (modeled after Perl example).*/
|
||||
$string = "I am a string"
|
||||
old = " a "
|
||||
new = " another "
|
||||
say 'The original string is:' $string
|
||||
say 'old word is:' old
|
||||
say 'new word is:' new
|
||||
$string2 = changestr(old,$string,new)
|
||||
say 'The original string is:' $string
|
||||
say 'The changed string is:' $string2
|
||||
/*stick a fork in it, we're done.*/
|
||||
14
Task/Regular-expressions/REXX/regular-expressions-4.rexx
Normal file
14
Task/Regular-expressions/REXX/regular-expressions-4.rexx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*REXX program shows test and substitute (modeled after Perl example).*/
|
||||
$string = "I am a string"
|
||||
old = " am "
|
||||
new = " was "
|
||||
say 'The original string is:' $string
|
||||
say 'old word is:' old
|
||||
say 'new word is:' new
|
||||
|
||||
if wordpos(old,$string)\==0 then
|
||||
do
|
||||
$string = changestr(old,$string,new)
|
||||
say 'I was able to find and replace ' old " with " new
|
||||
end
|
||||
/*stick a fork in it, we're done.*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue