replaceText() not working as expected for multiple lines
Paul Hibbert
paulhibbert at mac.com
Sun Sep 21 00:11:31 EDT 2014
The explanation of ^ that I found states, "The ^ (circumflex or caret) outside square brackets means look only at the beginning of the target string.", so the way I see it, if it's only looking at the beginning it's not going to repeat through the rest of the lines, so you could use a repeat loop (tested and it works) or just don't use the ^.
If I put…
/Users/hawk/bk_clients/blue aardvark/blue_aardvark____001.dhbk
/Users/hawk/bk_clients/pink panther/pink_panther_____001.dhbk
/Users/hawk/bk_clients/super chicken/super_chicken____005.dhbk
/Users/hawk/bk_clients/test5/test5____________001.dhbk
…into a variable tVar and use…
put replaceText(tVar,"/Users/hawk/bk_clients/",empty) into tVarOut
…then tVarOut contains:
blue aardvark/blue_aardvark____001.dhbk
pink panther/pink_panther_____001.dhbk
super chicken/super_chicken____005.dhbk
test5/test5____________001.dhbk
or simply…
replace "/Users/hawk/bk_clients/" with empty in tVar
…then tVar contains:
blue aardvark/blue_aardvark____001.dhbk
pink panther/pink_panther_____001.dhbk
super chicken/super_chicken____005.dhbk
test5/test5____________001.dhbk
I know replaceText can use regex, but as far as I can see in this case you are just removing a specific string…
…Or am I missing some point again?
Paul
On Sep 20, 2014, at 1:05 PM, Dr. Hawkins <dochawk at gmail.com> wrote:
> I have a variable with:
>
> /Users/hawk/bk_clients/blue aardvark/blue_aardvark____001.dhbk
> /Users/hawk/bk_clients/pink panther/pink_panther_____001.dhbk
> /Users/hawk/bk_clients/super chicken/super_chicken____005.dhbk
> /Users/hawk/bk_clients/test5/test5____________001.dhbk
>
> which was obtained with a shell command and ls on OSX
>
> Using replaceText() to replace ^/Users/hawk/bk_clients/ with empty, I get
>
> blue aardvark/blue_aardvark____001.dhbk
> /Users/hawk/bk_clients/pink panther/pink_panther_____001.dhbk
> /Users/hawk/bk_clients/super chicken/super_chicken____005.dhbk
> /Users/hawk/bk_clients/test5/test5____________001.dhbk
>
> That is, the ^ is only being applied to the variable as a whole, rather
> than to each line.
>
> Does this have to do with how livecode and OSX delimit lines?
>
> --
> Dr. Richard E. Hawkins, Esq.
> (702) 508-8462
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list