xsl-list
[Top] [All Lists]

[xsl] Ungready Flag on Regex

2020-10-08 09:23:05
Hello !

I have a regex that tries to detect bold parts in a markdown string.

In markdown, bold parts are delimited with ****. For example :

   Not bold but **this one is blod** text.

Here, *"this one is bold"* should be dispayed as bold text.

For this, I use this regex :

   <xsl:analyze-string select="$s" regex="\*\*[^*]*\*\*">
   ...
   </xsl:analyze-string>

Now, I have a string that contains comments markers, and these markers should be displayed in bold :

   Comments are delimited by **/* */** or prefixed by **//**

*/* */* should be in bold, *//* should be in bold, but *"or prefixed by"* should not be in bold.

My regex can't do that. But with PCRE (PHP) regex, I can use flag "U" (ungready, that make quantifiers lazy), and with this flag, I get exactly what I expect.

Is there an equivalent of Ungready tag, or a syntax that let me get what I want ?

Best regards,
Christophe
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>