Last active
February 6, 2019 03:16
-
-
Save hopewise/c1ab49258a2a9bf52c47 to your computer and use it in GitHub Desktop.
This script will replace all English numbers by Hindi numbers, it uses regular expression that exclude numbers between tags, ex: <h3>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var replaceDigits = function() { | |
var map = ["٠","١","٢","٣","٤", "٥","٦","٧","٨","٩"] | |
// replace english floating point with arabic one: | |
document.body.innerHTML = document.body.innerHTML.replace(/\d(?=[^<>]*(<|$))/g, function($0) { return map[$0]}); | |
// replace english floating point with arabic one: | |
document.body.innerHTML = document.body.innerHTML.replace(/\.(?=[^<>]*(<|$))/g, "٫"); | |
} | |
window.onload = replaceDigits; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Alot ,, good code