Anonymous user
String matching: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, added a better separator to the output.
m (→{{header|REXX}}: added/changed comments and whitespace, added a better separator to the output.) |
|||
Line 2,562:
say 'string A = ' A /*display string A to the terminal.*/
say 'string B = ' B /* " " B " " " */
say copies('░', 70)
if left(A, LB)==B then say 'string A starts with string B'
else say "string A doesn't start with string B"
Line 2,577:
else say "string A doesn't end with string B"
say
$=; p=0; do until p==0; p=pos(B, A, p+1)
if p\==0 then $=$',' p
end /*until
$=space(strip($, 'L', ","))
if #==0 then say "string A doesn't contain string B"
else say 'string A contains string B ' # " time"left('s', #>1),
▲ /*stick a fork in it, we're all done. */</lang>
{{out|output|text= when the following is specified (the five Marx brothers): <tt> Chico_Harpo_Groucho_Zeppo_Gummo p </tt> }}
<pre>
string A = Chico_Harpo_Groucho_Zeppo_Gummo
string B = p
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
string A doesn't start with string B
Line 2,603 ⟶ 2,602:
string A = Chico_Harpo_Groucho_Zeppo_Gummo
string B = Z
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
string A doesn't start with string B
Line 2,616 ⟶ 2,615:
string A = Chico_Harpo_Groucho_Zeppo_Gummo
string B = Chi
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
string A starts with string B
Line 2,629 ⟶ 2,628:
string A = Chico_Harpo_Groucho_Zeppo_Gummo
string B = mmo
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
string A doesn't start with string B
|