I need a regular expression to check that every word of some input begins with the same letter (and also allows certain punctuation).
Currently I have the following:
^(((\b[aA])\w*([\s\.\-\!\?\"\':,])*)+)|(((\b[bB])\w*([\s\.\-\!\?\"\':,])*)+)$
Going from [aA] all the way up to [zZ]
Obviously this isn’t the nicest way to go about it.
Does anyone have a smart regular expression?
Thanks.
Use backreferences with case-insensitive matching.