lundi 13 avril 2020

what is the regular expression get initial from string word in all language like chinese, arabic, cyrillic, hindi in Ruby

Currently I am using scan(/(\A\w|(?<=\s)\w)/) regular expression to get the initials from string word

Example str = "Sonu Singh"

str.scan(/(\A\w|(?<=\s)\w)/).flatten.join # output is "SS"

But this regexp is not working for other language like Cyrillic character, arabic, chinese, hindi etc. Can anyone help me to make signle regexp and get desired results.

Thank you so much any help or suggestion in any language.

Aucun commentaire:

Enregistrer un commentaire