开发者

Is it possible to filter both 'lava_rapido' and 'lava-rapido' using a simple REGEX?

I need to create a Google Analytics filter that helps me see data only for these url patterns:

http://www.xpto.com.br/local/lava-rapido

http://www.xpto.com.br/street/lava-rapido/lava-jato

http://www.xpto.com.br/em/state/lava-rapido

http://www.xpto.com.br/em/state_city/lava-rapido

http://www.xpto.com.br/local/state/cityname/lava_rapido/C404597429595E595D/xpto.html

Anybody could help me with that?

Thanks,

Dieg开发者_开发问答o


To answer the question in the header, here's the regex:

lava[-_]rapido

This allows either an underscore _ or dash -. You usually have to escape dashes - so they don't become ranges, but if a dash is at the beginning of a character class [-ABC], you don't have to.

To match any of the above urls (with dash or underscore), use this (urlPattern1|urlPattern2|urlPattern3):

http://www\.xpto\.com\.br/local/lava[-_]rapido|http://www\.xpto\.com\.br/street/lava[-_]rapido/lava-jato|http://www\.xpto\.com\.br/em/state/lava[-_]rapido|http://www\.xpto\.com\.br/em/state_city/lava[-_]rapido|http://www\.xpto\.com\.br/local/state/cityname/lava_rapido/C404597429595E595D/xpto\.html


If you need the exact match:

http://www\.xpto.com.br\/(local|street|em)(\/(state|state\_city))?(\/cityname)?/(lava-rapido|lava_rapido)/?(lava-jato)?([A-Z0-9]*/[a-z0-9]*\.html)?

Tested in http://regexpal.com/


This will match _ or -

lava[_\-]rapido
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜