For example , How to identify "jr or Dr or , jr or II or III in names like Gates II , Gates, jr and replace them. Any specific methods or using regex pattern?
assign this to a string variable
system.Text.RegularExpressions.Regex.Replace(oldName, "^([MDS]r|Ms)\.|(\s[IVX][IVX]+)|(\sjr)", "")
where oldName = your name containing Mr/Dr etc…
Hey, really appreciate your quick reply. Its working. However, if the name is like this “amber<,>jr” - need to replace <,> along with jr. also if the name is just “amber<,>jr” - need to replace ,jr. Is this achievable along with the above case?
Thanks !
you mean the name is like this:?
amber,jr
then use this regex
^([MDS]r|Ms)\.|(\s[IVX][IVX]+)|(,jr)
how about III, II etc…
is it
amber,II
or
amber II
?
like this amber,jr or amber,spacejr
use this
^([MDS]r|Ms)\.|([\s]?[,]?[IVX][IVX]+)|([\s]?[,]?jr)
Let me put clearly
Its like : Name,SPACEjr and Name,jr
NOT : NameSPACE,jr
yes it works with
name<space>
jr
and
name<,>jr
have you tested it yet?
Yeah, its working as you said for nameSPACEjr and name<,>jr. But is it possible to put like this name<,>SPACEjr
yes it works with amber<space><,>
jr
Sorry for the confusion. it was amber,SPACEjr
try this @TrinadhB
^([MDS]r|Ms)\.|([,]?[\s]?[,]?[IVX][IVX]+)|([,]?[\s]?[,]?jr)
@jack.chan Thank you! for your help
Hey, i have found that if name is like Varun V or Xareen X . its replacing even the first letters. Can you look into this?
^([MDS]r|Ms).|([,| ][,| ]?[IVX]+)|([,| ][,| ]?[,]?jr)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.