Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Tue Mar 19, 2019 8:44 pm
Probably a question for Thierry.
As an example I am trying to replace:
by
i.e. space out any adjacent capital letters.
So I search for an empty char which is preceded and followed by a cap letter and replace it by space:
Code: Select all
put replacetext( \
tGname, \
"((?<=[A-Z])(?=[A-Z]))", \
" ") \
into tGname
This works in other PCRE regex engines but not in LiveCode. Any ideas pls?
Kaveh
Kaveh
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10341
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Tue Mar 19, 2019 9:55 pm
Regex is powerful, like dataGrids. They also require considerable expertise. Thierry can likely do this in his sleep.
But Is the text you are dealing with too large to just let LC do it? A simple function would
transform "ABcED" to "A BcD E"
That is, if you really meant that spaces only separate adjacent uppercase chars. But in any case, straightforward.
Craig Newman
-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Tue Mar 19, 2019 11:04 pm
Hi Craig
Yes, I could do it with the beautiful LC script, but in a large text I think that one regex will be faster.
The main point of my query is whether LiveCode is not finding this by design, or am I doing something wrong, or is it a bug?
The regex works fine in other applications.
Kaveh
Kaveh
-
bogs
- Posts: 5480
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Wed Mar 20, 2019 11:01 am
Code: Select all
put replacetext( tGname, "((?<=[A-Z])(?=[A-Z]))", " ") into tGname
I'll say upfront I don't know the answer to your question, but I have a question for you, and that is, was your code full of continuation characters like it was put here? That line isn't exactly novel length, it would be hard to believe you did it not to stretch the script editor.
If it *does* have all those continuations in it, i'd eliminate those first, and make sure there wasn't an error caused by placement.
-
Thierry
- VIP Livecode Opensource Backer

- Posts: 875
- Joined: Wed Nov 22, 2006 3:42 pm
Post
by Thierry » Wed Mar 20, 2019 12:03 pm
Probably a question for Thierry.
At your service, Sir
Code: Select all
put replacetext( \
tGname, \
"((?<=[A-Z])(?=[A-Z]))", \
" ") \
into tGname
Hi Kaveh,
This will be my way to do it:
Code: Select all
put "([A-Z])(?=[A-Z])" into Rx
if sunnyreplace( "aABCdeFGZ.", Rx, "\1 ", R ) then put R
--> aA B CdeF G Z.
This works in other PCRE regex engines but not in LiveCode. Any ideas pls?
I'm curious which one works; please let me know where do you find it and
in which context; I may give you an explanation.
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
bogs
- Posts: 5480
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Wed Mar 20, 2019 12:28 pm
Now that is simple, elegant, and stunning, a pleasure to read

-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Wed Mar 20, 2019 12:43 pm
Hi Thierry
Thanks for you time as ever.
Does your solution require purchasing your software that does back-referencing?
The search string works in BBEdit, using the search string and replacing all with space.
Kaveh
-
Thierry
- VIP Livecode Opensource Backer

- Posts: 875
- Joined: Wed Nov 22, 2006 3:42 pm
Post
by Thierry » Wed Mar 20, 2019 1:08 pm
Hi Thierry
Thanks for you time as ever.
Does your solution require purchasing
your software that does back-referencing?
yes, sure
In fact, I'm shamelessly promoting my own development...
The search string works in BBEdit,
using the search string and replacing all with space.
Ok, I'll give you the explanation a bit later; too busy right now.
I guess you have the latest BBEdit version ?
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Wed Mar 20, 2019 1:23 pm
Keenly look forward to the explanation, Thierry
I am using very latest BBEdit (12.6.1)
Kaveh
-
Thierry
- VIP Livecode Opensource Backer

- Posts: 875
- Joined: Wed Nov 22, 2006 3:42 pm
Post
by Thierry » Wed Mar 20, 2019 1:55 pm
kaveh1000 wrote: ↑Wed Mar 20, 2019 1:23 pm
Keenly look forward to the explanation, Thierry
I am using very latest BBEdit (12.6.1)
Very quick but accurate answer:
Bbedit is using: PCRE2 Library version 10.33-RC1 2018-09-14
Livecode is using: PCRE Library version 9.3 ( from memory)
This makes all the differences.
You can read the diffs documentation at Philip Hazel web site...
Hope this help,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
kaveh1000
- Livecode Opensource Backer

- Posts: 539
- Joined: Sun Dec 18, 2011 7:23 pm
-
Contact:
Post
by kaveh1000 » Wed Mar 20, 2019 2:19 pm
Great. Thank you. That is the answer I was looking for. So at least:
- I have not put error in the expression
- it is not a bug
Thanks again. I will look for another method and report back if I find an elegant and fast solution
Kaveh
-
Thierry
- VIP Livecode Opensource Backer

- Posts: 875
- Joined: Wed Nov 22, 2006 3:42 pm
Post
by Thierry » Wed Mar 20, 2019 2:40 pm
kaveh1000 wrote: ↑Wed Mar 20, 2019 2:19 pm
Great. Thank you. That is the answer I was looking for.
Great.
Enjoy your day,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!