I want to write a regex pattern to match a string starting with "Z" and not containing the next 2 characters as "IU" followed by any other characters.
I am using this pattern but it is not working Z[^(IU)]+.*$
Try this regex:
^Z(?:I[^U]|[^I]).*$
Click for Demo
Explanation:
^
- asserts the start of the lineZ
- matches Z
I[^U]
- matches I
followed by any character that is not a U
|
- OR[^I]
- matches any character that is not a I
.*
- matches 0+ occurrences of any character that is not a new line$
- asserts the end of the lineIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With