English 中文(简体)
如何在特别安全局定期发表言论
原标题:How to write regular expressions in CSS

我如何在特别安全局中使用定期表述? 我找到了一个辅导网站,用于在国际空间站配对静态阵列,但我没有能够找到一个能够使用定期表达方式与安保部的多管齐下。 (I found one here,但我无法工作。 我还研究了。 W3C关于使用定期标识的文件,但我无法理解该文件。

I m want to match a series of <DIV> tags whose ids start at s1 and increase by one (ie. #s1 #s2 #s3...).

I know that div[id^=s], div[id^= s ], and div[id^= s ] each perform the match as I intend it in my CSS. However, each of those also match an id of #section, which I don t want to happen. I believe that "/^s([0-9])+$/" is the equivalent PHP string--I m just looking for it in CSS version.

最佳回答
问题回答
javascript:
    /* page scrape the DIV s# id s and generate the style selector */
    re=/<div[^>]*(id=(( |")?)s[0-9]+2)([^>]*)?>/ig;
    alert(
        document . body . innerHTML .
            match(re) . join("") .
                replace(re,"div[$1], ") + "{ styling details here }" );

    alert(
       ("test with <div id=s2 aadf><DIV ID=123> <DIV adf=asf as><Div id= s45 >" +
              "<div id=s2a ><DIV ID=s23 > <DIV asdf=as id=S9 ><Div id= x45  >") .
            match(re) . join("") .
                replace(re,"div[$1], ") + "{ styling details here }"
        );

The test yields

div[id=s2], div[id= s45 ], div[ID=s23], div[id=S9], { styling details here }

Note the dangling , and the case conservationS9.

If you don t want or can t use the solution posted by @zneak, you could do that editing the labels with javascript, but i ll advice you: It s a hell of work.

<style>
/* eliminate the alphabet except s - NB some funny characters may be left */
/* HTML id s are case-sensitive - upper case may need exclusion & inclusion */
div[id*=a], div[id*=b], div[id*=c], ..., div[id*=q], div[id*=r] {}
div[id*=t], div[id*=u], div[id*=v], div[id*=w], div[id*=x], div[id*=y], div[id*=z] {}
div[id*= _ ], div[id*= - ], div[id*= % ], div[id*= # ] {}

/* s can not be embedded */
div[id*=0s], div[id*=1s], div[id*=2s], ..., div[id*=9s] {}

/* s will be followed by a string of numerals - maybe a funny char or two */
div[id^=s0], div[id^=s1], div[id^=s2], ... div[id^=s9] { ... }
</style>




相关问题
Uncommon regular expressions [closed]

Recently I discovered two amazing regular expression features: ?: and ?!. I was curious of other neat regex features. So maybe you would like to share some tricky regular expressions.

regex to trap img tag, both versions

I need to remove image tags from text, so both versions of the tag: <img src="" ... ></img> <img src="" ... />

C++, Boost regex, replace value function of matched value?

Specifically, I have an array of strings called val, and want to replace all instances of "%{n}%" in the input with val[n]. More generally, I want the replace value to be a function of the match ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

Is it possible to negate a regular expression search?

I m building a lexical analysis engine in c#. For the most part it is done and works quite well. One of the features of my lexer is that it allows any user to input their own regular expressions. This ...

regex for four-digit numbers (or "default")

I need a regex for four-digit numbers separated by comma ("default" can also be a value). Examples: 6755 3452,8767,9865,8766,3454 7678,9876 1234,9867,6876,9865 default Note: "default" ...

热门标签