Skip to content

Instantly share code, notes, and snippets.

@uroybd
Last active February 10, 2018 13:04
Show Gist options
  • Save uroybd/ccda2bdb07ad38085cd406724b8229f8 to your computer and use it in GitHub Desktop.
Save uroybd/ccda2bdb07ad38085cd406724b8229f8 to your computer and use it in GitHub Desktop.
Javascript Regex to get 'Units' from Bengali text. (Useful for text transforming bengali with JS)
var bengaliUnitRegex = /([অ-হড়-য়](্[অ-হড়-য়])+|[অ-হড়-য়]্|[অ-হড়-য়])[া-ৌ]*[ঁঃং]*|ৎ|[০-৯]| /g;
// You can match with str.mathc(rg) and it will yield units as array. Example:
var testText = "আদর্শলিপি";
testText.match(bengaliUnitRegex);
// > ["আ", "দ", "র্শ", "লি", "পি"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment