View previous topic :: View next topic |
Author |
Message |
dmonckton Contributor
Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Sat Jan 12, 2019 2:45 pm Post subject: @match function |
|
|
Hi All
The @match function in v5 is crap!
I have a list which contains both mix & x, mix occurs first. If I use @match to find x it always finds mix instead(because it contains x). I want an exact match so wrote my own function to do it...
Code: |
:exMatch
rem %1 = list to search
rem %2 = string to find
list seek,%1,0
repeat
if @equal(@next(%1),%2)
%x = @pred(@index(%1))
end
until @not(@ok())%x
exit %x
|
Is there a better/faster way to do it? I concerned about the overhead of looping through the list each time.
Kind regards
David |
|
Back to top |
|
|
cnodnarb Professional Member
Joined: 11 Sep 2002 Posts: 762 Location: Rockeledge, GA
|
Posted: Thu Jan 17, 2019 4:27 am Post subject: |
|
|
I would continue to use the match function (in a loop) but reject results where the length of the string is greater than 1.
Still sucks, but should be faster than looping every line item. |
|
Back to top |
|
|
|