G'day everyone
(find) is like VBScript's Instr(). What is the equivalent for VBScript's RevInstr() wherein one searches for the first occurrence from the other end of the string? (find (reverse))?
Kind regards,
Bruce.
find is like Instr, what's like RevInstr?
Re: find is like Instr, what's like RevInstr?
I think I'll have a go at answering my own question.axtens wrote:What is the equivalent for VBScript's RevInstr() wherein one searches for the first occurrence from the other end of the string? (find (reverse))?
Code: Select all
(set 'reverse-find
(lambda (findThis inThis)
(- (length inThis) (find (reverse findThis) (reverse inThis)) (length findThis))))
Code: Select all
(set 'toFind "dog")
(set 'sentence "My first dog's fleas are on my second dog's blanket")
(println (slice sentence (reverse-find toFind sentence) (length toFind)))
; "dog"
(println (slice sentence (reverse-find toFind sentence)))
; "dog's blanket"
(println (slice sentence (find toFind sentence)))
; "dog's fleas are on my second dog's blanket"
Kind regards,
Bruce.
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact:
Yes, just not in Lisp. I've been in the IT business in various ways since 1983. At the moment I'm working for The Protium Project and MyTongue as a Software/Test Engineer. I program in a variety of languages, including Ada, assembler, (Visual) BASIC, C/C++, Delphi, Fortran, Perl, Protium, Tcl, and VBScript (and a few lesser known languages.)Kazimir Majorinc wrote:I think you are progressing quite good. Are you experienced programmer?
Kind regards,
Bruce.