I have a few pages of JSON to search like this:
"company": "chocolate factory"
"position": "founder"
"company": "chocolate packagers"
"position": "packager"
"company": "chocolate shop"
"position": "clerk"
I want to match only if the first occurrence of "position" isn't followed by founder. The preceding example wouldn't match, but the following would match.
"company": "chocolate factory"
"position": "taster"
"company": "chocolate packagers"
"position": "founder"
"company": "chocolate shop"
"position": "clerk"
This looks like this will match the first occurrence of "position"
("position": ")?
I think this should match the first occurrence of "position" only if it's not followed by "founder"
("position": ")?(?![^"]*founder)
I've tried it on regexr.com but it seems not to work right.
What's the correct way to do this?
Edit: So to clarify, I can only use a search box on a web app. I'm guessing it's a javascript regex but I can't really tell what flags are used (which makes things difficult)... but I think it's an SQL database doing the regex search if that makes sense.
I want to match only the first occurrence of "position"
(?:"position": ")?
but only if it's not followed by "founder"
(?:"position": ")?(?![^"]*founder)
or
(?:"position": "(?![^"]*founder))?
This kind of seems to work on testing sites, but it doesn't seem to work in the web app. Since I don't understand the backend, I'm probably not going to figure this one out.
Edit: I figured out the problem. The is postgresql regex - the escapes are slightly different, and it looks like how it searches is a little different too. Basically, I don't think what I wanted will work.