Why would [\d-]* not exclude numbers with dashes?

In a different thread of this forum (https://community.rws.com/product-groups/trados-portfolio/trados-studio/f/studio/52008/how-to-exclude-include-certain-elements-from-the-source-file-and-therefore-from-the-word-count-in-trados-studio-2022) I excluded numbers with dashes from translation using the embedded content processor for Word files.

To my surprise, [\d-]* did not work, at least the preview returned a blank editor - no segments. [\d+]+ did work. In my eyes, this is a bug.

Screenshot of RegexBuddy with a regex pattern highlighting a number with dashes in a test string.

RegexBuddy warns me: “C# (.NET 2.0–7.0) allows a zero-length match at the position where the previous match ends.”

But a zero-length match should not result in anything being converted into a tag.

Regex101 shows all the zero-length matches:

Screenshot of regex101.com showing multiple zero-length matches highlighted in a test string.

as opposed to

Screenshot of regex101.com with a regex pattern highlighting a number with dashes in a test string.

but IMHO this should not affect the conversion into tags.

(All for .NET 7.0)



Generated Image Alt-Text
[edited by: RWS Community AI at 12:31 PM (GMT 0) on 14 Nov 2024]
emoji
Parents Reply Children