Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex to match to end of line with wildcard

I need to match a URL in google analytics for use in a goal and a funnel.

I would like to match a url for http://url.com/guides/anything-that-comes-after

I will be matching /guides on it's own goal, but would like to match /guides/* (how I would do it with a simple wildcard) with the regex.

like image 291
Rapture Avatar asked Jan 23 '12 13:01

Rapture


People also ask

How do you end a line in RegEx?

End of String or Line: $ The $ anchor specifies that the preceding pattern must occur at the end of the input string, or before \n at the end of the input string. If you use $ with the RegexOptions. Multiline option, the match can also occur at the end of a line.

What does RegEx 0 * 1 * 0 * 1 * Mean?

Basically (0+1)* mathes any sequence of ones and zeroes. So, in your example (0+1)*1(0+1)* should match any sequence that has 1. It would not match 000 , but it would match 010 , 1 , 111 etc. (0+1) means 0 OR 1.

What is difference [] and () in RegEx?

[] denotes a character class. () denotes a capturing group. [a-z0-9] -- One character that is in the range of a-z OR 0-9.


1 Answers

So you're trying to match anything that comes after "guides/", basically?

^http\:\/\/url\.com\/guides\/(.+)$

should match anything after your based URL. If you want to make it domain independent, try this:

^http\:\/\/.+?\/guides\/(.+)$
like image 138
Rohaq Avatar answered Oct 10 '22 23:10

Rohaq