A regular expression to match a string delimited by characters that does not contain the delimiters

I’m looking for the regex expression for a string matching a string starting with a ; and ending with a :, that contain neither ; nor :

For example “;zreazer:” should match but “;raz:er:” or “;er;:” should not.

Any idea? 🙂 Thanks in advance, I tried some with ^ and ?! symbols but it didn’t work out very well.

I believe you’re looking for

;[^;:]*:

; and : are the delimiters. [^;:] will match any string in between the delimiters that does not include these delimiters.

Here’s a Regex101 demo. I’ve added double quotes to the expression to make it obvious.


A good reference for regular expressions can be found here in the Python docs.