1

Match all lowercase letters which are followed by two or more capital letters then three or more digits: (the capital letters and digits should not be included in the match) in python

I tried this but not working:[a-z]?![A-Z]{2,}[0-9]{3,}.

1 Answer 1

2

Use your current approach, but put the capital letters followed by numbers assertion into a positive lookahead:

[a-z](?=[A-Z]{2,}[0-9]{3,})

This pattern says to:

[a-z]          match a lowercase letter
(?=            then lookahead (but do NOT consume)
    [A-Z]{2,}  2 or more uppercase letters
    [0-9]{3,}  followed by 3 or more digits
)

Lookaheads assert, but not consume, in a regex pattern.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.