String matching: Difference between revisions
→{{header|J}}: faster/more efficient contains
m (→{{header|J}}) |
(→{{header|J}}: faster/more efficient contains) |
||
Line 61:
<lang j>startswith=: ] -: ({.~ #)
contains=:
endswith=:] -: ({.~ -@#)</lang>
Line 82:
'abab' contains 'ab'
1
'abab' I.@E.~ 'ab' NB. find starting indicies
0 2</lang>
Note that these verbs also apply to arrays of type other than character so:
<lang j> 0 1 2 3 startswith 0 1 NB. integer
1
4.2 5.1 1.3 9 3 contains 1.3 4.2 NB. floating point
0
4.2 5.1 1.3 4.2 9 3 contains 1.3 4.2
1</lang>
=={{header|Java}}==
|