Posts: 97
Threads: 48
Joined: Sep 2010
Hello again!
Is it possible to search for an item in text for example "item" and then select everything between the last item "test" above it?
Any help would be nice!
Greetings
Sonic
Posts: 12,098
Threads: 142
Joined: Dec 2002
Function
FindLast
;/
function# $s1 $s2 [flags] ;;flags: 1 case insensitive, 2 whole word
;Finds the last substring.
;Returns its first character index, or -1 if not found.
str a(s1) b(s2)
if(a.len<b.len or b.len=0) ret -1
strrev a
strrev b
int ins=flags&1
int i=iif(flags&2 findw(a b 0 "" flags&1|64) find(a b 0 flags&1))
if(i<0) ret i
ret a.len-i-b.len
Posts: 97
Threads: 48
Joined: Sep 2010
Thx Gintaras !
So when i have a text like this:
Hello
Goodbye
Goodbye
Hello
Goodbey
Twelve monkeys
I can with this function extract the last part? So i get this:
Hello
Goodbey
Twelve monkeys
Can you show me an example please?
Posts: 12,098
Threads: 142
Joined: Dec 2002
Macro
Macro477
str s=
;Hello
;Goodbye
;Goodbye
;Hello
;Goodbey
;Twelve monkeys
int i=FindLast(s "Hello" 2)
if(i<0) end "not found"
str s2.get(s i)
out s2