hyperTTS - Text Replacement Rules - How to remove a single letter?

Hello,

I’m using hyperTTS for my vocabulary cards. Since not everything that is on the card should be spoken, I’m using the Text Replacement Rules. I have a problem when individual letters should not be output, such as f for feminine or m for masculine. E.g. “la signora f”. When I create a “Simple Rule” with Pattern “f” and Replacement " ", the f disappears in all words. Can someone help me how to solve this problem?

Thanks!

Try using this text replacement rule:

  • Type: Regex
  • Pattern: ^(.*?) \D$
  • Replacement: \1

Brief explanation:

  • ^ asserts the position at the start of a line.
  • ( ) defines a capturing group, which captures the part of the string matched inside the parentheses.
  • . matches any character (except line terminators).
  • *? is a lazy quantifier that matches the preceding token zero or more times, but as few times as possible.
  • \D matches any character that is not a digit.
  • $ asserts the position at the end of a line.
  • \1 in the replacement pattern inserts the content captured by the first capturing group (the text matched inside (.*?)).

For more info, see https://regex101.com/, which is very useful for testing purposes, and also regex - Rust, for documentation.

1 Like

Many thanks for your response. I had no experience with regular expression
rules before. I’ve dealt with it a bit now. I’ve adapted your suggestion slightly because I only want to remove the letters m and f. The following seems to work for me:

  • Type: Regex
  • Pattern: ^(.*?)[\s(?fm]$
  • Replacement: \1
1 Like