Skip to content

Instantly share code, notes, and snippets.

@hopewise
Last active February 6, 2019 03:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hopewise/c1ab49258a2a9bf52c47 to your computer and use it in GitHub Desktop.
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>
<script type="text/javascript">
var replaceDigits = function() {
var map = ["&#x660;","&#x661;","&#x662;","&#x663;","&#x664;", "&#x665;","&#x666;","&#x667;","&#x668;","&#x669;"]
// 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, "&#x066B;");
}
window.onload = replaceDigits;
</script>
@ExpertTIC
Copy link

not ENglish Numbers , it's ARABIC numbers hhhh
1.2.3.4.5....

@hoodasaad
Copy link

Thanks Alot ,, good code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment