A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

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".

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Never mind, I got it working.

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi, perhaps you could put your solution online, it could be helpful for some people. Thanks

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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 /\.

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.