Mohammad wrote:
>
> At https://regex101.com/ the below syntax return errors it needs the
> slash character to be escaped!
>
Mark's detailed answer to why that happens (and why it is *not *an issue in
TW) is really clear.
I think it may be worth adding a note about the way that TW relates to the
underlying JS regex engine.
Tools like TW that access the engine usually use an interface that is
defined by the end programmers.
Its part of the same issue of understanding how the "scope" flags "g" and
"m" are invoked in TW.
This can be important in matching in the text field, which TW can do, but
needs a bit more documentation to be optimally used.
TT
On Friday, 6 September 2019 06:29:13 UTC+2, Mark S. wrote:
>
> There's a difference in javascript between a regular expression, and a
> string that can be interpreted as a regular expression.
>
> If you notice at regex101, the input box has* / *at the start and end. So
> it's assuming a direct regular expression, like:
>
> */*^(([^/]+?)/){1}[^/]+?$*/*gm
>
> The slashes are used to indicate the start and end of the expression, and
> so any slashes in the middle not part of a character class throw an error.
>
> But we're actually passing a string here. So internally something like
> this is happening:
>
> var patt = new RegExp(*"^(([^/]+?)/){1}[^/]+?$"*) ;
>
> Since the forward slash is not needed to delimit the expression when the
> regular expression is created this way, it doesn't throw an error inside of
> TW.
> It's unfortunate that the tool at regex101 doesn't allow you to enter the
> expression as a string.
>
> -- Mark
>
>>
>> *Advanced use of the Negated Character Class*
>>>
>>> *Match titles with defined numbers of "/" slash*
>>> *^(([^/]+?)/){1}[^/]+?$*
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/e6bd5cbe-1b1c-4e8f-b53d-3504d05546e5%40googlegroups.com.