In Code Like A Girl. More on Medium.

Regular expressions. So powerful, but so tricky to learn!
Recently I found myself scratching my head over how to write a regular expression to check that a string contained only lowercase characters.
I used so many different combinations of[a-z], ^\W, [0–9], [a-z]^\W and more. No dice. I couldn’t figure out the correct combination. Finally I thought: oh, so simple, I’ll just do the inverse! So I did the following:
const isLowercaseOnly = (string) => {
const nonLowercaseLetters = /[^a-z]/g;
return !nonLowercaseLetters.test(string);
};This works, but now I have to deal with inverse. A bit confusing.
Luckily, I was working with…
A space that celebrates Women in Technology.