You should open a thread in
https://ulmf.org/forums/h-game-discussions-tech-help-recommendations.323/
I believe your issue isn't with the game (or this'd be the right place), but with the program/hooker you're using.
Be sure to mention what software you're using, what language you'd be using the regex with, what code would be used to prevent repetition, if you know.
Right now, competent people (AKA not me) can't see you're asking for help, and if they did you wouldn't be providing much info about your issue.