10-03-2013 10:46 AM
Spoiler
**EDIT 2** : LOL, Lithium forum parser, you're so silly when it comes to curse words and special character sequences
There is definitely something emotionally resonant about seeing a sad-smiley in the middle of a long regex. 🙂
10-06-2013 11:11 AM
Spoiler**EDIT 2** : LOL, Lithium forum parser, you're so silly when it comes to curse words and special character sequences
Maybe the issue here is that the parser is using a regex?
10-07-2013 07:07 AM
Maybe we could ask for a Verbose field in the Lithium editor to identify sections of text not to be interpreted. We have an "insert code" toolbar item, which I've never used. Here's a test of Jack's reg ex that created an emoticon in the middle:
(?:/s*)?(?<!\\)"(.*?)(?<!\\)"(?:/s*)??:/s*)?(?<!\\)"(.*?)(?<!\\)
10-07-2013 08:28 AM
If you go into your profile settings, then Preferences, then Display, change the setting for the Emoticon Type from Default to None.
Now you won't see the automatic emoticons.
10-07-2013 05:05 PM
hello,
How to have the "opposite" of a reference ?
(sorry for my bad english, i do my best)
(3)[^3] matches "32", "3a" ...
I would like to replace the second term < [^3] > by a reference to the first term < (3) > .... ...\1 instead of [^3]
The problem is the " ^ " ... and obviously, (3)[^\1] does not work !
in other words, all except " \1 "
is there a way to do that ?
Thanks to all, ( x )
10-07-2013 09:29 PM
@ouadji wrote:
hello,
How to have the "opposite" of a reference ?
Yo, ouadji -- check out Negative Lookaheads, and the following regex:
(3)(?!\1)
The way to read this entire regex is:
I have a suspicion this regex is not sufficient for what you're needing -- if that's the case, can you provide more test vectors of inputs and expected outputs? Or, if this nudges you in the right direction, reply with the final regex you implement! Thanks!
10-08-2013 03:29 AM
thank you Jack
(3)(?!\1) ... good idea ...
but,
with an input string " 3313 ", this expression matches " 3 " .. this is not the result I would like to get.
i would like to have " 31"
the second term is just a condition of matching!,
and the second character is not included in the match.
(3)(?(?!\1).|^) works ! (it's my best-shot, I have not yet found a better way!)
if the next character is not equal to "3", THEN "this character" ... else 'start of the line" ("start of the line" is an impossible condition)
(again, sorry for my bad english, it's not easy for me)
10-08-2013 05:49 AM
I sent a feature request to the author of PCRE
Except in the special case of "character classes",
PCRE has no general character to get "the opposite of".
I think this is a gap, it should be possible to get (easily) the opposite of a reference.
for exemple, just a idea, why not like this : ~\n
11-06-2013 10:25 AM
@JackDunaway wrote:
Looks like nothing a couple lookarounds as zero-width assertions can't handle.
Try (?<=\[ABC\]\[)(.*?)(?=\]) with the Search and Replace String Node, ensuring to turn on Regular Expression matching via it's right-click menu option.
One deficiency of Lookbehinds is the inability to declare a variable-width match. (Lookaheads, on the other hand, allow variable-width matches)
Notice in the quoted snippet, the lookbehind is looking for a fixed-width match -- [ABC][
What happens, for instance, if our application domain does not allow us to constrain the lookbehind as fixed-width?
Try replacing the Lookbehind with the escape sequence \K which excludes everything preceding from the whole match.
The original regex (?<=\[ABC\]\[)(.*?)(?=\]) could be rewritten as \[ABC\]\[\K(.*?)(?=\])
To make that original regex even more powerful for matching any arbitrary variable-width value inside the initial braces, we could write this as: \[.*?\]\[\K(.*?)(?=\])
And to take it one step futher if necessary, add a capturing group to grab the arbitrary value inside the initial braces: \[(.*?\)]\[\K(.*?)(?=\])
\K is great for excluding all matches prior from the whole match, while still allowing capturing subgroups to be returned as submatches.
01-06-2014 05:16 PM
XKCD, again.