匹配所有字符串,直到指定的字符串出现在 urlrewrite.xml 中
match all strings until specified one occurs in urlrewrite.xml
我正在尝试实现这样一种情况:
将重写为
path=a1&attributes=b2,c3&splitters=d4,e5
(or more like
somepath.html?path=1&attributes=$[numberOfGroup]&splitters=$[numberOfGroup])
到目前为止,我已经设法创建了类似
的东西
<from>^/(?!whatever/)(.*),a([0-9]+)(,(.+))?.html(\?(.*))?$</from>
<to last="true">somepath.html?path=&attributes=&</to>
很明显我已经更改了这部分代码:
(,(.+))
具有以下含义:匹配每个字符串(示例:b3、c56、e12345)以“,”分隔,直到遇到特定字符串("stop"),然后继续匹配直到遇到“.”
我试过使用
(,(.+?(?=stop)))?
在
<from>^/(?!whatever/)(.*),a([0-9]+)(,(.?!(?=stop)))?,stop(,(.+))?.html(\?(.*))?$</from>
没有成功的结果,因为 'stop' 仍然作为普通字符串进行匹配,而我重写的 url 看起来像这样:
"somepath.html?path=54&attributes=a1,b2,c3,stop,d4,e5&"
如果有人引导我找到有效的解决方案,我将不胜感激。
尝试在 from
标记中使用以下表达式:
^[^,]+,(a[0-9]+),(.*?),stop,?(.*)$
请注意,这是一个非常通用的表达式。上面没有花哨的matches/groups。如果任何匹配的组是可选的,请使用 ?
使它们成为可选的。
现在,在重写的 URL:
somepath.html?path=&attributes=&splitters=
我正在尝试实现这样一种情况:
将重写为
path=a1&attributes=b2,c3&splitters=d4,e5
(or more like somepath.html?path=1&attributes=$[numberOfGroup]&splitters=$[numberOfGroup])
到目前为止,我已经设法创建了类似
的东西<from>^/(?!whatever/)(.*),a([0-9]+)(,(.+))?.html(\?(.*))?$</from>
<to last="true">somepath.html?path=&attributes=&</to>
很明显我已经更改了这部分代码:
(,(.+))
具有以下含义:匹配每个字符串(示例:b3、c56、e12345)以“,”分隔,直到遇到特定字符串("stop"),然后继续匹配直到遇到“.”
我试过使用
(,(.+?(?=stop)))?
在
<from>^/(?!whatever/)(.*),a([0-9]+)(,(.?!(?=stop)))?,stop(,(.+))?.html(\?(.*))?$</from>
没有成功的结果,因为 'stop' 仍然作为普通字符串进行匹配,而我重写的 url 看起来像这样:
"somepath.html?path=54&attributes=a1,b2,c3,stop,d4,e5&"
如果有人引导我找到有效的解决方案,我将不胜感激。
尝试在 from
标记中使用以下表达式:
^[^,]+,(a[0-9]+),(.*?),stop,?(.*)$
请注意,这是一个非常通用的表达式。上面没有花哨的matches/groups。如果任何匹配的组是可选的,请使用 ?
使它们成为可选的。
现在,在重写的 URL:
somepath.html?path=&attributes=&splitters=