Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search the string in the opposite direction
#1
Hi,

In a multi-line strings, Searches for the location of the specified string
The last matching line, from left to right, is the position of the first matching string
For example, in the following example: abĀ abc bbb abc

Thanks in advance for any advice and help
david

Macro Macro1
Code:
Copy      Help
_s=
;abc
;efg
;hij
;abc
;klm
;ab abc bbb abc
;ccc
int pos=find(_s "abc" 0)
out pos
#2
Macro Macro3234
Code:
Copy      Help
_s=
;abc
;efg
;hij
;abc
;klm
;abc bbb abc
int pos=sub._Find(_s "abc")
out pos

#sub _Find
function# str's1 $s2

ARRAY(lpstr) a
tok s1 a -1 "[10]" 1
int i
for i a.len-1 -1 -1
,lpstr s3=a[i]
,int j=find(s3 s2)
,if(j>=0) ret s3-s1+j
ret -1
#3
Worked well, Thanks for your helpĀ  Smile


Forum Jump:


Users browsing this thread: 1 Guest(s)