February 18th, 2010, 08:27 AM
Capture up to the first slash [WAS: Simple regex question]
This shouldn't be difficult for regex masters. I have a text like this:
I need a regexp that would match "folder1" in both cases. There can be nothing after "folder1" or there can be a slash and some other text that i need to discard. While writing this post, i've figured i could do /^([a-zA-Z]+).*$/, but i'd still like to know if there's any other way to do this (like some sort of an OR operator). I know there should be some combination of | and (), but i just don't know how i'd use that.
February 18th, 2010, 08:43 AM
i.e. capture all characters from the start of the string that aren't forward slashes.
Comments on this post