replaceText() not working as expected for multiple lines

Mike Bonner bonnmike at gmail.com
Sat Sep 20 19:02:19 EDT 2014


You could change your shell call, and use sed inline to strip what you
don't want before sending it back to LC
Since I don't know how you're generating the list, i'm using find to do it
on .mov files
Quote the whole string, use a pipe to sed with the -e switch, surround the
string for sed with single quotes.  escape slashes with a backslash.  also
escape . with a backslash (necessary in my case since i'm using find from
the current dir.  If find was "find / -name...", or a full path to the
start location, it wouldn't be necessary to have the preceeding .
The following example, finds all .mov files starting in the defaultfolder,
and removes /skyDrive/ from the beginning.  Replaces it with nothing (hence
the // at the end)

put shell("find . -name *.mov | sed -e 's/^\.\/skyDrive\///'") into tDat

On Sat, Sep 20, 2014 at 3:46 PM, Peter Haworth <pete at lcsql.com> wrote:

> You might try (?m) to switch on multiline mode at the start of your regex.
> I'm pretty sure that won't work though.  LC makes you use a repeat loop to
> go through each line and issue the replaceText() against each one.
>
> Hope that Thierry chimes in with a workaround for this - he's the LC regex
> King.
>
> Pete
> lcSQL Software <http://www.lcsql.com>
> Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
>
> On Sat, 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
> >
> _______________________________________________
> 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