Suppose I have string coming from Input with name (for eg: Mr . Aditya Jha
). How do I remove salutation from the start of input?
List of salutations that can come are:
Mr, Mrs, Dr, Miss, Ms, Rev, Mr. , Mr. , Dr. , Miss. , Ms. , Rev. , Mr . , Mr . , Dr . , Miss . , Ms . , Rev .
Any solution or regex statement which can consider all of these salutations?
I tried this:
name.replaceAll("\\s{2,}", " ").replaceFirst("(?i)(Mr . )", "").replaceFirst("(?i)(Mr |Mr. )", "").trim()
It is working, but for name like amra khan
, it is removing mr
.