Reputation: 184
Right now, this regex matches something and stops at a slash ( / ), but I need it to stop at the slash and include the slash. Or in other words stop at whatever character is after the slash. But, I don't know what that charcter is.
Any ideas on how to do this?
Here is the regex:
(?:https?:\/\/|www)[^\/]*
Upvotes: 1
Views: 2882
Reputation: 7739
You can do it in 2 ways :
(?:https?:\/\/|www)[^\/]*\/
or this :
(?:https?:\/\/|www).*?\/
Edit:
To stop at the lasts slash use this :
(?:https?:\/\/|www)[^\/]+(?:\S*?\/)*
Upvotes: 2
Reputation: 56769
Add the slash as part of your regular expression:
(?:https?:\/\/|www)[^\/]*\/
^^ add this
Upvotes: 0