Can someone help me with a regular expression? I'm trying to use grep to match any line that contains "/wallpaper/[letters and numbers]/[numbers]_[letters]_1440x900.jpg", and it won't work. What I currently have is "/wallpaper/[0-9a-z]+/[0-9]+_[a-zA-Z]+_1440x900\.jpg".
Never mind, I got it working.
Hi, perhaps you could put your solution online, it could be helpful for some people. Thanks
I'm so sorry I didn't, of course. Somehow it was the plus operators that caused it to not work. I'm not sure if grep simply doesn't support them or something, but when I replaced plus with star, it worked perfectly.
Ah, for grep you'll probably want to use \+ instead. Depending on what software you're using, sometimes some characters need to be escaped to take on their special meaning. In vim, for example, the default is to treat () as regular parentheses but treat \(\) as a capturing group, which is the opposite of the way it works in, say, Perl or Ruby or Python.
Using star is not an option, doesn't do the same thing as a +. You can work around it if you want, but + is the better solution. Also, you need to escape your slashes /\.
Join our real-time social learning platform and learn together with your friends!