另一个正则表达式 - 如何识别查询字符串
我正在使用 urlrewriting.net 进行 url 重写。我需要一些关于正则表达式的帮助(我仍然没有得到......)。
我想匹配
www.mysite.com/restaurant
->匹配并返回 “餐厅
”www.mysite.com/restaurant?page=1
->匹配和 返回“restaurant
”www.mysite.com/restaurant?[SOME_RANDOM_QUERYSTRING]
->匹配 并返回“restaurant
”www.mysite.com/seattle/restaurant
->匹配并返回“seattle
”并且 “餐厅
”www.mysite.com/seattle/restaurant?page=1
->匹配和 返回“seattle
”和“restaurant
”www.mysite.com/seattle/restaurant?[SOME_RANDOM_QUERYSTRING]
->匹配 并返回“seattle
”和“restaurant
”www.mysite.com/seattle/restaurant-michelangelo
->不要赶上www.mysite.com/seattle/restaurant/sushi
->匹配并返回“seattle
” 和“餐厅
”和“寿司
”www.mysite.com/seattle/restaurant/sushi?page=1
->匹配并返回 “西雅图
”和“餐厅
”和“寿司
”www.mysite.com/seattle/restaurant/sushi?[SOME_RANDOM_QUERYSTRING]
-> 匹配并返回“seattle
”和“restaurant
”和“sushi
”www.mysite.com/seattle/restaurant-michelangelo< /代码> ->不明白
要点是我需要 url 的目录部分而不是查询字符串部分。问题是,我可以从我的网络分析工具中看到,人们通过两个词进行搜索。他们都搜索城市(西雅图)+类别(餐厅),例如。 “西雅图餐厅”以及城市(西雅图)+餐厅名称(餐厅-米开朗基罗),例如。 “西雅图餐厅-米开朗基罗”。从结构的角度来看,这当然是一团糟,因为这不是一个层次结构。在理想的世界中,层次结构将是城市 ->类别->餐厅。但我仍然想在我的网址结构中容纳这种搜索行为。同时我还有一个页面列出了该国所有的餐馆。
我希望获得有关如何创建正则表达式以及创建它们的最有效方法的帮助,因为我猜它们可能会变得相当昂贵。
谢谢
托马斯
I am using urlrewriting.net for my urlrewriting. I need some help on the regex (which I still don't get....).
I would like to match
www.mysite.com/restaurant
-> match and return
"restaurant
"www.mysite.com/restaurant?page=1
-> match and
return "restaurant
"www.mysite.com/restaurant?[SOME_RANDOM_QUERYSTRING]
-> match
and return "restaurant
"www.mysite.com/seattle/restaurant
-> match and return "seattle
" and
"restaurant
"www.mysite.com/seattle/restaurant?page=1
-> match and
return "seattle
" and "restaurant
"www.mysite.com/seattle/restaurant?[SOME_RANDOM_QUERYSTRING]
-> match
and return "seattle
" and "restaurant
"www.mysite.com/seattle/restaurant-michelangelo
-> don't catchwww.mysite.com/seattle/restaurant/sushi
-> match and return "seattle
"
and "restaurant
" and "sushi
"www.mysite.com/seattle/restaurant/sushi?page=1
-> match and return
"seattle
" and "restaurant
" and "sushi
"www.mysite.com/seattle/restaurant/sushi?[SOME_RANDOM_QUERYSTRING]
->
match and return "seattle
" and "restaurant
" and "sushi
"www.mysite.com/seattle/restaurant-michelangelo
-> don't catch
The point being I need the directory-parts of the url and not the querystring-parts. The thing is that I can see from my web analytics tool, that people search by two words. They both search for the city (seattle) + category (restaurant) eg. "seattle restaurant" and also for the city (seattle) + the name of the restaurant (restaurant-michelangelo) eg. "seattle restaurant-michelangelo". From a structural point of view, this is of course a mess, since this is not a hierarchy. In the ideal world the hierarchy would be city -> category -> restaurant. but I would still like to accommodate this search behavior in my url-structure. At the same time I also have a page listing all restaurants in the country.
I would like help on how to create the regexes as well as the most efficient way of creating them since I guess they could become quite expensive.
thanks
Thomas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用这个:
匹配/字母数字 1-无穷大,然后斜杠、行尾或问号
use this:
Matches / Alphanumerics 1-infininity then slash, End of Line, or Question mark