Match both of these with regex, not just one of -


i'm looking in sql table through bunch of names , want list of different titles used. e.g. snr, mrs, mr, jnr etc

sometimes there entry might have 2 titles, e.g: mr name name jnr. want both of these titles 'mr' & 'jnr'

i thought way regex , find names have 2 or 3 characters. title @ front followed space, while title @ end preceded one. have:

/(^[a-z]{2,3})\s|\s(^[a-z]{2,3}$)/ 

a regex101 example here.

as can see i've used 'match either or b' thing. if throw @ name title @ either start or finish, end getting want, don't know how tell both. i.e. strings 2 titles give me 1 match.

how both?

instead of "or", match character in between:

(^[a-z]{3})\s.*\s([a-z]{3}$)


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -