Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
48
Task/String-matching/NetRexx/string-matching.netrexx
Normal file
48
Task/String-matching/NetRexx/string-matching.netrexx
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref savelog symbols
|
||||
|
||||
lipsum = ''
|
||||
x_ = 0
|
||||
x_ = x_ + 1; lipsum[0] = x_; lipsum[x_] = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
|
||||
x_ = x_ + 1; lipsum[0] = x_; lipsum[x_] = lipsum[1].reverse
|
||||
|
||||
srch = ''
|
||||
srch[1] = 'Lorem ipsum dolor sit amet'
|
||||
srch[2] = 'consectetur adipisicing elit'
|
||||
srch[3] = 'dolore magna aliqua.'
|
||||
|
||||
loop j_ = 1 to lipsum[0]
|
||||
x1 = lipsum[j_].pos(srch[1])
|
||||
x2 = lipsum[j_].pos(srch[2])
|
||||
x3 = lipsum[j_].lastpos(srch[3])
|
||||
|
||||
report(x1 = 1, lipsum[j_], srch[1], 'Test string starts with search string:', 'Test string does not start with search string:')
|
||||
report(x2 > 0, lipsum[j_], srch[2], 'Search string located in test string at position:' x2, 'Search string not found within test string:')
|
||||
report(x3 \= srch[3].length, lipsum[j_], srch[3], 'Test string ends with search string:', 'Test string does not start with search string:')
|
||||
end j_
|
||||
|
||||
many = ''
|
||||
x_ = 0
|
||||
x_ = x_ + 1; many[0] = x_; many[x_] = 'How many times does "many times" occur in this string?'
|
||||
x_ = x_ + 1; many[0] = x_; many[x_] = 'How often does "many times" occur in this string?'
|
||||
x_ = x_ + 1; many[0] = x_; many[x_] = 'How often does it occur in this string?'
|
||||
srch[4] = 'many times'
|
||||
|
||||
loop j_ = 1 to many[0]
|
||||
o_ = 0
|
||||
k_ = 0
|
||||
loop label dups until o_ = 0
|
||||
o_ = many[j_].pos(srch[4], o_ + 1)
|
||||
if o_ \= 0 then k_ = k_ + 1
|
||||
end dups
|
||||
report(k_ > 0, many[j_], srch[4], 'Number of times search string occurs:' k_, 'Search string not found')
|
||||
end j_
|
||||
|
||||
method report(state = boolean, ts, ss, testSuccess, testFailure) public static
|
||||
if state then say testSuccess
|
||||
else say testFailure
|
||||
say ' Test string:' ts
|
||||
say ' Search string:' ss
|
||||
say
|
||||
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue