Wrong String Replace

Hi everyone,

I created a small sample project called Sentence Tester. As you can see at the pictures, it creates dynamically event sentences. Keywords will replaced by the values of the event, if they are not empty.
There are conditional keywords. This is the structure: <prefix [keyword] suffix>. The prefix and the suffix are optional. The string should only printed, if the value is not empty. On the second picture you can see, the year will not printed correctly. Why?

Thanks!

In the replacement pattern, replace the slashes with dollar signs.

   rx.ReplacementPattern = "$1" + type +  "$3"

Great, that works fine. Whats the difference using slashes and dollar signs in RegEx?

Replacement patterns are not part of the PCRE engine so each vendor designs their own way of doing it. In this case, Xojo uses both “” and “$” to reference subgroups, and the difference is, “” didn’t work the way you wanted and “$” did.

:slight_smile: