Code: Select all
(?<![A-Za-z])TeX(?![A-Za-z])
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
(?<![A-Za-z])TeX(?![A-Za-z])
Umm, since LC 6.5, PCRE lib is 8.33, before it was 6.7.kaveh1000 wrote:Am I right that these are not implemented in the regex engine in LiveCode?
I give you a secret here:I am using this code:to find the word "TeX" when not preceded or followed by another letter.Code: Select all
(?<![A-Za-z])TeX(?![A-Za-z])
Code: Select all
(\bTeX\b)
lookbehind is not efficient.kaveh1000 wrote:Thanks a lot Thierry. I did eventually find that \b and it works
But there must be instances where look-ahead etc are the only way, or do you think not? If not, I would be happier not to use them as the code is simpler too and as you say faster.
thanks for the advice.
Regards
Kaveh
Hi Kaveh,kaveh1000 wrote:OK Thierry. There is no escape now!
The common mistake we do is to think that replacteText(), matchXXX() and the replacementStringHow do I replace a pattern in LiveCode?
So simple case of transposing two words, change
(abc)(def) to
\2\1
I tried \1 but I get a literal \1.
Code: Select all
put "Thierry Douez LiveCode Regex" into theText
put "(\w+)\s+(\w+)" into theRegex
put "\2 \1" into smartReplacement
if sunnYreplace( theText, theRegex, smartReplacement, outString) then
answer theText & " is now: " & outString
end if
BBEdit is a perfect tool for that andkaveh1000 wrote: As time was short I have had to write my script another way (BBEdit and AppleScript),
I told you there was no escape! Going off topic here but the only way I found of stringing together several regexp replacements as a script is by recording each and saving as an AppleScript. Unfortunately AppleScript is so bloated, and also escapes characters again, leading to unreadable code, e.g.Thierry wrote:BBEdit is a perfect tool for that andkaveh1000 wrote: As time was short I have had to write my script another way (BBEdit and AppleScript),
you certainly know that "Bare Bones" uses the PCRE library
Thierry
Code: Select all
replace "{\\[}{\\[}(.+){\\]}{\\]}" using "~\\\\ref{\\1}" searching in text 1 of text document "rfp.tex" options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
As it goes off-topic,kaveh1000 wrote: <...>
the only way I found of stringing together several regexp replacements as a script is by recording each and saving as an AppleScript. Unfortunately AppleScript is so bloated, and also escapes characters again, leading to unreadable code..
Any quick hint of another way of doing this within BBEdit?