@6degrees/arabic-strings
Advanced tools
Comparing version 0.1.1 to 0.2.0
# @6degrees/arabic-strings | ||
## 0.2.0 | ||
### Minor Changes | ||
- enhanced removeNonArabic to accept excluded characters | ||
## 0.1.1 | ||
@@ -4,0 +10,0 @@ |
@@ -27,4 +27,5 @@ "use strict"; | ||
} | ||
static removeNonArabic(str) { | ||
return str.replace(/[^\u0621-\u0652]/gm, ""); | ||
static removeNonArabic(str, excludeChars = "") { | ||
const exclusionRegex = new RegExp(`[${excludeChars}]`, "gm"); | ||
return str.replace(new RegExp(`[^\\u0621-\\u0652${excludeChars}]`, "gm"), "").replace(exclusionRegex, ""); | ||
} | ||
@@ -110,5 +111,4 @@ static removeArabic(str) { | ||
arabicStrings.TA = /[ة]/g; | ||
arabicStrings.TASHKEEL_REGEX = new RegExp("[" + _arabicStrings.TASHKEEL.join() + "]", "g"); | ||
// /[\u064B-\u0652] | ||
arabicStrings.TASHKEEL_REGEX = new RegExp(_arabicStrings.TASHKEEL.join(""), "g"); | ||
arabicStrings.TATWEEL_REGEX = /ـ/g; | ||
module.exports = arabicStrings; |
{ | ||
"name": "@6degrees/arabic-strings", | ||
"license": "MIT", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.mjs", |
@@ -37,3 +37,4 @@ class arabicStrings { | ||
static TA = /[ة]/g; | ||
static TASHKEEL_REGEX = new RegExp("[" + arabicStrings.TASHKEEL.join() + "]", 'g'); // /[\u064B-\u0652] | ||
static TASHKEEL_REGEX = new RegExp(arabicStrings.TASHKEEL.join(""), "g"); | ||
static TATWEEL_REGEX = /ـ/g; // /\u0640/g | ||
@@ -73,5 +74,7 @@ | ||
static removeNonArabic(str: string): string { | ||
return str.replace(/[^\u0621-\u0652]/gm, ""); | ||
} | ||
static removeNonArabic(str: string, excludeChars: string = ""): string { | ||
const exclusionRegex = new RegExp(`[${excludeChars}]`, "gm"); | ||
return str.replace(new RegExp(`[^\\u0621-\\u0652${excludeChars}]`, "gm"), "").replace(exclusionRegex, ""); | ||
} | ||
@@ -78,0 +81,0 @@ static removeArabic(str: string): string { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18082
333