How to write a regular expression for something that does NOT start with a given word
Let's suppose I have the following list
I want a regular expression that returns all but June and July because they they start with Ju
I wrote something like this ^[^ju] but this return any starting with J or U I need something that starts with Ju
Try this regular expression:
^([^j].*|j($|[^u].*))
This matches strings that either do not start with j
, or if they start with j
there is not a u
at the second position.
If you can use look-around assertions, you can also use this:
^(?!ju).*
If 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