Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search in reverse order?
#1
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
#2
Function FindLast
Code:
Copy      Help
;/
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
#3
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?
#4
Macro Macro477
Code:
Copy      Help
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


Forum Jump:


Users browsing this thread: 1 Guest(s)