ReplaceText: back refs in replacement string
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark
ReplaceText: back refs in replacement string
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
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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: ReplaceText: back refs in replacement string
You're making me want to brush up on my RegEx Thierry
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: ReplaceText: back refs in replacement string
<g>monte wrote:You're making me want to brush up on my RegEx Thierry
Please, don't.
I wouldn't like to feel responsible for any brain damage..
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: ReplaceText: back refs in replacement string
@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
@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
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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: ReplaceText: back refs in replacement string
So we can't use back references in LC at present?Thierry wrote: As we can already use back references in our regex (2nd parameter),
I think keeping the same syntax is fine : \1, \2, ...
Re: ReplaceText: back refs in replacement string
@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.
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
@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
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: ReplaceText: back refs in replacement string
@monte: I thought there might be a simpler way - thanks