-
Notifications
You must be signed in to change notification settings - Fork 113
/
index.ts
24 lines (20 loc) · 837 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { ArabicContextualForms } from "../../helpers";
/**
* Check if string is Arabic
*
* @param {string} str
* @param {object} trimPattern Pattern of characters which you want to trim from the string e.g. "-+. ()"
* @return {boolean} Return true if the entered string does not include other-language characters.
*/
export const isArabic = (str: string, trimPattern = /["'-+()\s.]/g): boolean => {
const text = str.replace(trimPattern, "");
return /^[\u0600-\u06FF\s]+$/.test(text) && ArabicContextualForms.test(text);
};
/**
* Check if string includes Arabic alphabet.
*
* @param {string} str
* @return {boolean} Return true if the entered string includes persian characters
*/
export const hasArabic = (str: string): boolean => /[\u0600-\u06FF]/.test(str) && ArabicContextualForms.test(str);
export default isArabic;