Problem with standard regex

Scott Kostyshak skostysh at lyx.org
Sat Jan 2 17:59:28 UTC 2021


On Sat, Jan 02, 2021 at 06:45:21PM +0100, Kornel Benko wrote:
> Am Sat, 2 Jan 2021 09:23:00 -0500
> schrieb Scott Kostyshak <skostysh at lyx.org>:
> 
> > On Sat, Jan 02, 2021 at 12:47:13PM +0100, Kornel Benko wrote:
> > > Given the string
> > > 	t = "\foreignlanguage{russian}{\texttt{\label}"
> > > and trying to use
> > > 	"regex_replace(t, t,
> > > 	"\\\\(emph|noun|text(bf|sl|sf|it|tt)|(u|uu)line|(s|x)out|uwave)(\\{(\\{\\})?\\})+",
> > > 	"")
> > > leads to regex-exception.
> > > Anything other than "\label" works. (e.g. "\xyzzy" or "\lxabel", or "\labelx")
> > > 
> > > Does anyone know, what's going on here?
> > > (It does not even depend on "\texttt", because already
> > > 	t = "\foreignlanguage{russian}{\label"
> > > leads to the exception.  
> > 
> > Does the exception give any message? Does it give more information if
> > you catch the exception and print the message, like the following?
> > 
> >   https://en.cppreference.com/w/cpp/regex/regex_error
> > 
> > Scott
> 
> In the meantime I make a small example. Compiled, and to my surprize, it went OK.
> Further investigating shows the error in my own code (out of range access).
> The following exception was catched in the try {} section in findAdv(), so the only
> message was: "Invalid regular expression!". This was misleading.

Indeed that's not very helpful. Ideally it would say *why* it is not valid.

> Committed at 8c67cb8c.

Nice.

Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210102/6363022a/attachment.asc>


More information about the lyx-devel mailing list