I need to make a QLineEdit with a QRegularExpressionValidator with the following 3 constraints:
- Cannot start with empty space
^[\\S] - Cannot start with Hello
^(?!Hello).+ - Cannot end with empty space
^.*[\\S]$
How do I combine those 3 in one regex so that I can set it a QRegularExpressionValidator?
Thank you!
Note: As long as I have a regex that is verifiable with a regex tool I am good. I have specified Qt just to provide more context.
You could use
Explanation
^Start of string(?!Hello\b)Negative lookahead, assert what is directly to thte right is not Hello\SMatch a non whitespace char(?:.*\S)?Optionally match 0+ times any char except a newline and a non whitespace char$End of stringRegex demo