Detect Text Direction Using JavaScript – is-rtl-text

Category: Javascript , Text | October 14, 2022
Author:codeeshop-oc
Views Total:332 views
Official Page:Go to website
Last Update:October 14, 2022
License:MIT

Preview:

Detect Text Direction Using JavaScript – is-rtl-text

Description:

is-rtl-text is a small JavaScript utility used to detect whether your text belongs to a Right To Left language.

How to use it:

1. Download and import the is-rtl-text.

const isRtlText = require('is-rtl-text')
// OR
<script>var exports = {};</script>
<script src="./lib/is-rtl-detect.js"></script>

2. Detect the text direction using Regex, and it will return true if the text is in RTL language.

// false
isRtlText('Hello World');
// true
isRTL('رحبا بالعالم');

You Might Be Interested In:


Leave a Reply