选择阿拉伯语文本中的括号 [英] Selecting parenthesis in Arabic text
问题描述
我复制了一些阿拉伯语文本并将其粘贴到我的网站上.现在我想在这个阿拉伯语文本中选择括号:http://jsfiddle.net/t6Kdc/>
I copied some Arabic text and pasted it on my website. Now I want to select the parentheses in this Arabic text : http://jsfiddle.net/t6Kdc/
<span>
كهيعص ﴿١﴾
</span>
jQuery(function () {
var oldHtml = jQuery('span').html();
var newHtml = oldHtml.replace("(","<span style='color: red'>﴾</span>");
jQuery('span').html(newHtml);
});
但出于某种原因,我无法选择它们.为什么?
For some reason though, there's no way I can select them. Why ?
推荐答案
那些不是正则括号,那些是来自 Unicode 阿拉伯文字的括号.它们表示为:
Those are not regular parenthesis, those are parenthesis from Arabic script in Unicode. They are represented as:
U+FD3E ﴾ arabic ornate left parenthesis
U+FD3F ﴿ arabic ornate right parenthesis
(您可以在 维基百科上的 Unicode 阿拉伯语脚本)
要在 jQuery 中替换它们,您可以执行以下操作:
To replace them in jQuery, you can do the following:
var newHtml = oldHtml.replace("\ufd3e","<span style='color: red'>(</span>");
(替换左括号)
var newHtml = oldHtml.replace("\ufd3f","<span style='color: red'>)</span>");
(替换右括号)
这篇关于选择阿拉伯语文本中的括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!