Skip to content

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

Notifications You must be signed in to change notification settings

YazeedAlsaif/arabicString

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

#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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%