Skip to content

Latest commit

 

History

History
110 lines (77 loc) · 1.86 KB

README.md

File metadata and controls

110 lines (77 loc) · 1.86 KB

#arabicString

A Javascript library that extends the native String object with methods to help when dealing with Arabic strings for node and the browser.

##Usage ###node

require('arabicString')

###browser

<script src="arabicString.js"></script>

##String#howArabic()

The percentage of Arabic letters in the String.

Example

'foobar'.howArabic()
//=> 0.0
'فوو bar'.howArabic()
//=> 0.5
'فوبار'.howArabic()
//=> 1.0

##String#howNotArabic()

The precentage of non-Arabic letters in the String.

Example

'فوبار'.howNotArabic()
//=> 0.0
'فوو bar'.howNotArabic()
//=> 0.5
'foobar'.howNotArabic()
//=> 1.0

##String#isArabic(threshold)

Is the String Arabic, based on a given threshold between 0 and 1. Defaults to 0.79.

Example

'فوو'.isArabic()
//=> true
'فوو bar baz'.isArabic(0.5)
//=> flase

##String#hasArabic()

Does the String have any Arabic letter.

Example

'فوو bar'.hasArabic()
//=> ture
'foo bar'.hasArabic()
//=> false

##String#removeTashkel()

Will return the String without the diacritics

Example

'مٌحمْد'.removeTashkel()
//=> 'محمد'
'وَتُرى الْكَوَاكِبِ فِي الْمَجَرَّةِ شَرَعَا*** مِثْلُ الظِّباءِ كوارعا فِي جَدْوَلِ'.removeTashkel()
//=> 'وترى الكواكب في المجرة شرعا *** مثل الظباء كوارعا في جدول'

##String#removeNonArabic()

Will return the String without the non-Arabic letters

Example

'hello مرحبا'.removeNonArabic()
//=> 'مرحبا'

##String#removeArabic()

Will return the String without the Arabic letters

Example

'hello مرحبا'.removeArabic()
//=> 'hello'

License

MIT

Copyright © 2012 - Ahmad Salman