String matching: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: corrected a spelling error, added comments and more whitespace within literals, use "true" IFs, removed FOREVER from DO statement. |
|||
Line 1,413:
----
=={{header|NewLISP}}==
<lang NewLISP>(setq str "abcdefbcghi")
;; test if str starts with "ab"
(starts-with str "ab")
;; find "bc" inside str
(find "bc" str)
;; test if str ends with "ghi"
(ends-with str "ghi")
;; function to list positions of pattern inside str
(define (positions pattern str)
(let ((idx -1) (pos '()))
(while (setq idx (find pattern str 0 (+ idx 1)))
(push idx pos -1))))
(positions "bc" str)</lang>
=={{header|Nimrod}}==
<lang nimrod>import strutils
|