I'm trying to write a function to determine if an input is "shouting". Which hear means writing in all caps. The logic I'm using for that is
if (this.toUpperCase() === this)
Which is working just fine, however, the problem I've having is that strictly numerical or symobolic (?, ! etc.) strings are being flagged as shouting.
I've tried something to the effect of
if (this.toUpperCase() === this && !this.match(/a-zA-Z/))
However, that doesn't seem to do the trick. Does the mistake lie in my javascript or my regex? Thanks in advance for any help!
!this.match(/[a-z]/) && this.match(/[A-Z]/)?[a-zA-Z]this.match(/[^a-z]/)instead to make the intent clearer.