English 中文(简体)
Converting php regexp to Java
原标题:Converting php regexp to JavaScript

我试图将以下的营地表达方式转化为 Java语,但我有一点麻烦。

preg_replace( / .preg_quote($keyword). /i , "<span>$0</span>", $string)

这里发生的情况是,我可以重新利用被发现的带有正确“书面信”的内容。 很难解释我所说的话,但让我举一个例子:

如果用户投入减少,那么这种扼杀就是所有下级信函。 但是,因此,这个词与瑞典是一样的,因此,我希望它保持其案件。

如你在“Thephp”的表述中看到的那样,在“php”中,可以使用相应的价值0美元来做到这一点。

在 Java文中,我迄今所做的是:

var highlighted_sub = location_sub_name[i].replace(regexp_highlight,"<span class= loc_keyword >" + location_keyword + "</span>");

这用用户的投入取代了原来的结果,因此,当我实际上想要案件与实际情况一样时,我会把所有低级案例的简况作为用户的投入。

最佳回答

在javascript中,你可以这样做;唯一的例外是,“实体匹配”背书是$&而不是$0。 其余部分,$1 through $9,但实际相同。 在您的浏览器的地址:

javascript: document.write( foobar .replace(/(f)[o]/g,   $1 $&  ));

http://www.ual-expressions.info/refreplace.html” rel=“nofollow” http://www.erra-expressions.info/refreplace.html

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签