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".
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
Never mind, I got it working.
Hi, perhaps you could put your solution online, it could be helpful for some people.
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.
Not the answer you are looking for? Search for more explanations.
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 /\.