English 中文(简体)
我怎么写过一个reg子,无视从某个特定预设点开始的扼杀,把其他一切都归入一个集团?
原标题:How do I write a regex that ignores strings starting with a particular prefix, and captures everything else into a single group?

<<>Background:

我试图提出改写规则的reg子,该规则将涉及任何并非从某种特定预先确定开始的事情,并添加这一条。 但是,已经有预设的遗体应当被经常表达方式所拒绝(因为它们已经有ur)。

<>>Example:

序号为s1 a 如home,将包含home部分。 但是,像<条码>s1/home这样的缩略语将无法捕获任何东西。

这样,我就能够把抓捕团体添加到预设点上,以便家庭变成家畜。

我曾尝试过<代码>(^s1/),但我在此没有东西,因为那是出于某种原因拒绝回家的。

最佳回答
^(?!prefix)(.+)

替换

prefix$1

解释:

^         # start-of-string
(?!       # begin negative look-ahead
  prefix  # your prefix (take care to properly regex-escape it)
)         # end negative look-ahead
(.+)      # capture the complete string to group $1
问题回答

Try a look-ahead claim:

^(?!s1).*(home)

这与<代码>home <>/code>不从<代码>1开始的任何指示相匹配。





相关问题
Session Management with Windows Authentication

In an ASP.NET web app, using Integrated Windows Authentication, is the session tied to the windows identity? In other words, if I login (using IWA) to the app, and the app stores some "stuff" in my ...

Using Elmah with Cassini

Does anyone know if I can use Elmah with Visual Studio build-in web server(aka Cassini)? I get it working easily on IIS, but using same configuration, it doesn t work with Cassini. When I requested ...

Setting hostname in IIS, include www?

I want to set the hostname for a website I m adding in IIS 7, however do I include the www in the hostname or not? because I want both www.mysite.com and mysite.com both to point to mysite on the ...

inetpub versus any other folder

I ve run websites out of inetpub, as well as from folders just residing on the C: drive. I wonder, are there any definitive advantages to running websites out of inetputwwwroot?

IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

热门标签