English 中文(简体)
Java 常规表述,不含字
原标题:Javascript Regular Expression excluding a word
问题回答

当你开始使用<代码>^的特性类别时(如您在<代码>[^”/>>中已有的),是指“除所列特性外的任何特性”。 http://www.un.org/Depts/DGACM/index_chinese.htm

If you re trying to match the text between two slashes (//) and one backslash () (as per your question; you later made a comment suggesting it s two backslashes, I address that later), then:

var match = str.match(///(.*?)\/);    // Match between // and 

请注意,由于冲突是经常表达的限定词,我们必须避免冲突,因为反弹是越狱。

以上指“两lash,后一lash为零或以上,之后为后lash”。 www.un.org/Depts/DGACM/index_french.htm 非消费性(因此,其消费的特性可能满足这一表述)。 <>代码>( 创建capture group<>em>,在对应标的中,该组将获得与该职位相应的特性。

例:

test("foo");
test("foo //bar");
test("foo //bar\");
test("foo //bar\ baz");
test("bar\ baz");
test("//bar\ baz");
test("foo //bar\ baz \ more \ more");

function test(str) {
    var m = str.match(///(.*?)\/),
        cap = (m && m[1]) || "<em>nothing</em>";
    display("Str: <code>" + str + "</code>: Captured <code>" + cap + "</code>");
}

产出:

范围:<0>

Str: foo /bar: Captured nothing

Str:foo /bar: 页: 1

范围: 页: 1

Str: bar baz : Captured nothing<>>>。

Str:/bar baz: 页: 1

Str:foo /bar baz more: 页: 1

Live copy

Or for two backslashes:

var match = str.match(///(.*?)\\/);  // Match between // and \

Live copy (the output is the same, just with two backslashes)

Some reading on JavaScript regular expressions:

怎么说

var tokens = str.split(///|\\/);




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