String matching: Difference between revisions

m
→‎{{header|REXX}}: consolidated '''output''' specifications, changed format of program slightly. -- ~~~~
No edit summary
m (→‎{{header|REXX}}: consolidated '''output''' specifications, changed format of program slightly. -- ~~~~)
Line 1,351:
=={{header|REXX}}==
Extra coding was added to take of using plurals in the messages.
<lang rexx>/*REXX program to showdemonstrates some basic character string testing. */
 
parse arg a b
say 'string A=' a
Line 1,371 ⟶ 1,370:
say
 
Ps=''; p=0; do forever until p==0
Ps=''
p=pos(b,a,p+1)
p=0
do forever until if p\==0 then Ps=Ps',' p
end /*forever until p==0*/
p=pos(b,a,p+1)
if p\==0 then Ps=Ps',' p
end /*forever*/
 
Ps=space(strip(Ps,'L',","))
times=words(Ps)
Line 1,383 ⟶ 1,379:
times 'time'left('s',times>1),
"(at position"left('s',times>1) Ps')'
else say "string A doesn't contains string B"</lang>
 
'''output''' when the following is specified (five Marx brothers):
/*stick a fork in it, we're done.*/</lang>
<br><br>
'''output''' when the following is specified (five Marx brothers): <tt> Chico_Harpo_Groucho_Zeppo_Gummo p </tt>
<pre style="overflow:scroll">
string A= Chico_Harpo_Groucho_Zeppo_Gummo
Line 1,399 ⟶ 1,395:
string A contains string B 3 times (at positions 10, 23, 24)
</pre>
'''output''' when the following is specified: <tt> Chico_Harpo_Groucho_Zeppo_Gummo Z </tt>
<br><br>
Chico_Harpo_Groucho_Zeppo_Gummo Z
<pre style="overflow:scroll">
string A= Chico_Harpo_Groucho_Zeppo_Gummo
Line 1,414 ⟶ 1,408:
string A contains string B 1 time (at position 21)
</pre>
'''output''' when the following is specified: <tt> Chico_Harpo_Groucho_Zeppo_Gummo Chi </tt>
<br><br>
Chico_Harpo_Groucho_Zeppo_Gummo Chi
<pre style="overflow:scroll">
string A= Chico_Harpo_Groucho_Zeppo_Gummo
Line 1,429 ⟶ 1,421:
string A contains string B 1 time (at position 1)
</pre>
'''output''' when the following is specified: <tt> Chico_Harpo_Groucho_Zeppo_Gummo mmo </tt>
<br><br>
Chico_Harpo_Groucho_Zeppo_Gummo mmo
<pre style="overflow:scroll">
string A= Chico_Harpo_Groucho_Zeppo_Gummo