English 中文(简体)
如何定期发表承认每一表述的表述?
原标题:How to write a regular expression that recognises each expression individually?
  • 时间:2012-04-26 13:26:56
  •  标签:
  • regex
  • jsp

I m试图写一个与《共同财产法》中的以下法典相符的包裹:

="<%= "Index: " + index %>"

然而,如果我以一般方式就与这一目的相匹配的同一行文发表以下表述:

value="<%= "items[" + Index + "].selected" %>" id="<%= "Checkbox" + Index %>"

谁能帮助我看一看花板,以分别确认价值和tag子,以便我能够用单一报价取代外部双quot?

Thanks, Alexei Blue.

P.s. So far I have this which isn t specific enough:

"=<%=.*".*".*%>"
最佳回答

如果你想要与整个“设计、百分率和”要素相匹配,包括报价,无论在标签内(除百分比外)什么。

"<%=[^%]+%>"

您很可能需要从该法典的引文中删除:>>

它说的是:

  • Match "<%
  • match everything that s not a %
  • match %>"

<>光线>

如果你对内部双重引用的内容特别感兴趣,则使用:

"<%=([^%]*"){2}[^%]+%>"
  • ([^%]*"){2}: match everything that s not % (optional) and a double quote - repeat twice
  • [^%]+: match any remaining characters
问题回答

你可以尝试:

<%=s*”(+?)” (+?)s*%>

<代码><>>>><>+>后,<代码>+匹配程度尽可能低。





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

热门标签