Page 1 of 1

ReplaceText: back refs in replacement string

Posted: Wed Oct 09, 2013 10:49 am
by Thierry
Hi,

For those liking regex, here is one nice feature missing:

put replaceText( "aaa bbb", "(\w+)\s+(\w+)", "\2\1")
--> bbb aaa

As we can already use back references in our regex (2nd parameter),
I think keeping the same syntax is fine : \1, \2, ...

Well, guess it's enough for a start :)

Any thoughts on this?

Regards,

Thierry

Re: ReplaceText: back refs in replacement string

Posted: Wed Oct 09, 2013 11:00 pm
by monte
You're making me want to brush up on my RegEx Thierry

Re: ReplaceText: back refs in replacement string

Posted: Thu Oct 10, 2013 5:03 am
by Thierry
monte wrote:You're making me want to brush up on my RegEx Thierry
<g>
Please, don't.
I wouldn't like to feel responsible for any brain damage..

Re: ReplaceText: back refs in replacement string

Posted: Mon Oct 14, 2013 9:29 am
by LCMark
@Thierry: This would be a neat addition... The only thing I'd suggest is making it a different function name for handling 'patterns' in the replacement string - maybe replaceTextWithPattern? This existing code that has '\n' in replacement strings will still work as expected :)

Re: ReplaceText: back refs in replacement string

Posted: Mon Oct 14, 2013 10:26 am
by Thierry
@runrevmark I'm fine with a new function.

Just to be sure, I guess that by *This existing code*, you mean old user's code, yes?

I have more options for this function in mind.. ( inspired by the Perl substitute s/// )
Is this better to talk about all of them right now
or later when I'll be ready to code them?

And 2 more questions from a benevolent contributor:

1) is there some possibility to organize a tchat
with one of the core LC developers for very precise questions about the engine code?

2) still loosing some hair(1) trying to understand how to stay in sync with all the repos:
--- origin runrev github: livecode and thirdparty module
--- my thierrydouez github forks: livecode and thirdparty module
--- my local repos

Having a libpcre_8_33 branch on my thirdparty local and github repo,
how do I do to start working with the latest runrev develop branch?

Regards,

Thierry

(1) don't worry, no much left anyway :)

Re: ReplaceText: back refs in replacement string

Posted: Tue Oct 22, 2013 10:58 am
by garyth123
Thierry wrote: As we can already use back references in our regex (2nd parameter),
I think keeping the same syntax is fine : \1, \2, ...
So we can't use back references in LC at present?

Re: ReplaceText: back refs in replacement string

Posted: Fri Oct 25, 2013 8:33 am
by LCMark
@Thierry: Yes - by 'the existing code', I meant existing code that uses replaceText().

Feel free to discuss any thoughts you have on options for the function and such, others might have input that will help evolve them.

In terms of your other questions...

1) This sounds like a good idea - I'll see what I can do in the near future. In the mean time, do post any queries you have here and I'll try and answer them.

2) Yes - it can get a bit tricky with all the branches and submodules floating around. It has taken me a while to get used to git (we were using subversion for a *long* time before we went open-source, the mental transition has taken a while). It seems to me that the default 'clone' option that github has is not really suitable for the work-flow we have for accepting pull-requests - the issue being we (runrev) are the only ones who write to any of the branches - it ends up with you having to remember to keep updating master and develop in your fork, which is a bit silly since they should (essentially) be read-only. Therefore I've started doing this:

Checkout my fork of livecode (runrevmark)
Delete the master / develop and any release branches locally and remotely
Add runrev/livecode.git as a remote (git add runrev https://github.com/runrev/livecode.git)
Then checkout the runrev develop / master etc. branches directly e.g. git checkout -b master runrev/master

This last step links the local master branch to the runrev master branch meaning that when you switch to it and do 'git pull', you get the latest changes - rather than having to indirect through the master branch in your fork on github.

If you want to (as you have) modify the submodules, then you can do a similar thing - change the remote repo reference in the submodule to your clone, and remap the master / develop etc. branches to point to the runrev submodule repo.

Re: ReplaceText: back refs in replacement string

Posted: Tue Oct 29, 2013 4:20 am
by monte
@runrevmark you can change the remote tracking branches using:

Code: Select all

git remote add upstream https://github.com/runrev/livecode.git
git branch -u upstream/master master
git branch -u upstream/develop develop

Re: ReplaceText: back refs in replacement string

Posted: Tue Oct 29, 2013 10:27 am
by LCMark
@monte: I thought there might be a simpler way - thanks :)