I'm new to regular expressions, and I couldn't figure out how to get this to work by just googling it. I think part of my problem might be that I'm having trouble phrasing the question in search terms.
Here's my problem:
I have a string that looks like this:
OSDfhosjdjakjdnvkjndkfvjelkrjejrijrvrvrjvnkrjvnkn(mint (light) green pants)shdbfhsbdhfbsjd(couch)hvbjshdbvjhsbdfbjs(forest (dark) (stained) green shirt) sjdfjsdhfjshkdfjskdjfksjdfhfskdjf(table)
I want to select the entire contents of the parentheses containing the word "green," and only those parentheses. That is to say, I want to return "mint (light) green pants" and "forest (dark) (stained) green shirt" but not "couch", "table", or any of the gibberish.
What I've tried so far:
/(.*?green.*?/)
seemed to return an almost arbitrary block of text surrounding "green" and beginning and ending with a /, which makes me think I screwed up escaping the parentheses somehow./(.*green.*/)
seemed to return the entire document.Googling the problem: It seems from the pages I'm finding here and on google that what I want is a lookbehind, a regex functionality that JavaScript doesn't support. Unfortunately, I'm working in JS, so I need a way to make this work.
Edited: I just realized that the text I want to be outputting contains more parentheses than I originally realized, and edited my example to reflect this.