Something like charIndex, but in a variable...

Thierry Douez th.douez at gmail.com
Thu Apr 30 11:16:52 EDT 2015


> orange banana tomato
> banana tomato orange
> tomato banana orange

Experimenting with regex...
Sorry, couldn't resist :)


function MalteCharIndex T, nWord, nLine, at p1, @p2
   get format( "(?mx)(?: .*? \\n){%d}   (?: (\\w+) [\\W]*){%d}", nLine
-1, nWord)
   return matchChunk( T,  IT, p1, p2)
end MalteCharIndex


and run it this way:

on mouseUp
   put  field "fEntry" into theText
   put 5 into nLine
   put 7 into nWord
   if MalteCharIndex(  theText, nWord, nLine, tStart, tEnd) then
      select  char tStart to tEnd of fld "fEntry"
   else
      beep
   end if
end mouseUp

Did a couple of tests and looks good so far.

Sure, a lot of room for improvement.

Thierry


------------------------------------------------
Thierry Douez - http://sunny-tdz.com
Maker of sunnYperl - sunnYmidi - sunnYmage




More information about the use-livecode mailing list