RosettaCodeData/Task/String-matching/Forth/string-matching.fth

6 lines
203 B
Forth
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
: starts-with ( a l a2 l2 -- ? )
tuck 2>r min 2r> compare 0= ;
: ends-with ( a l a2 l2 -- ? )
tuck 2>r negate over + 0 max /string 2r> compare 0= ;
\ use SEARCH ( a l a2 l2 -- a3 l3 ? ) for contains