Chris
Chris

Reputation: 10061

regex for lowercase letter or period followed by an uppercase letter

Originally I just wanted to find a lowercase letter followed by an uppercase letter, in which case [a-z][A-Z] worked out pretty well.

However, in some cases the lowercase letter is replaced by a period. I'm fairly new to regex and haven't been able to find a way to implement this explicity in regex (my current solution runs through a few if statements and feels quite inelegant.

Is this something that can be handled well by regex?

Upvotes: 2

Views: 2298

Answers (1)

Anirudh Ramanathan
Anirudh Ramanathan

Reputation: 46728

[a-z.][A-Z]

Read about character classes. One character out of those specified is matched by it.


Additionally: If you were using the . outside a character class, you would need to escape it as it is a regex meta-character.

Upvotes: 6

Related Questions