I am creating a web text editor that uses a new language I created (like BBcode). This markup language will be in Arabic but I am facing these problems :
- It's really hard to mix English and Arabic text in the same line in all IDE's and editors, because strange things happen (the order of words and characters changes)
- when replacing a text with javascript using a pattern the Arabic text doesn't appear
(eg:
"1 text arabic here 1".replace(/1(*)1/,"($1)")
I get empty () )
How can I fix this ?
Perhaps you can use some unlikely deliminator character to specify points in your data buffers where your encoding switches. This would let your parsing functions identify chunks of your files that have to be treated differently.
I don't know if your arabic text uses UTF-8 characters. Hopefully it is possible to render all necessary characters in both english and arabic in UTF-8. Then you can use your delimiter to tell your other code how to handle pieces of text that behave differently.
Dunno about the regex, hopefully there are libraries on github that handle mixed arabic and english regex already :)
edit: Stack Overflow's markdown ate some stuff the first time (and god knows what it did to my pasted arabic lorem ipsum)
edit: here's a start to find the arabic tags