English 中文(简体)
替代(吗?!y)
原标题:Alternative to (?!y) but before a word

如果想排除“pple”的话,为什么我可以 use(!y)pple?

What is alternative to (?!y) before a word?

http://jsfiddle.net/ksevelyar/SbCCx/4/

最佳回答

www.un.org/Depts/DGACM/index_spanish.htm 回答你原来的问题:。

您可以精-地加入“由任何东西(str)或非自然特性所取代”的编码。

/(?:^|[^y])apple/

或视你想要做些什么,你可以使用一字边界匹配。

/apple/

 matches the boundary between an alphanumeric character (w) and a non-alphanumeric character (W)


其他一些环境(如Perl)有时具有这种眼光背后的功能,很容易地建立在以下方面:

/(?=)/   positive lookahead
/(?!)/   negative lookahead
/(?<=)/  positive lookbehind
/(?<!)/  negative lookbehind

www.un.org/Depts/DGACM/index_spanish.htm 关于在之前不替换物品的问题

或许,如果你进行两个步骤:首先从你身上删除<代码><pre>内的所有案文,然后进行替换,然后在你完成之后添加隐藏的文本。

问题回答

(?!) is a lookahead, which will look over the end of their regex to seek (or not found, in this case because its a anti-lookahead) nature.

You probably wanted to write a lookbehind, or (?<!...). Something like /(?<!y)apple/, however they aren t supported by the javascript regular expression engine.

但是,看不到替代物的答案,但是,如果不更好地了解你试图做些什么,就很难相互建议。

JavaScript s regexp is not the best one... Here is a (very) dirty workaround which might suit you:

str = str.replace(/<pre>apple</pre>/g, "#DUMMY#");
str = str.replace(/apple/g, "sword");
str = str.replace(/#DUMMY#/g, "<pre>apple</pre>");

http://jsfiddle.net/pZ3c9/"rel=“nofollow> http://jsfiddle.net/pZ3c9/

希望这将有助于你们!





相关问题
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.

热门标签