Search code examples
cregexposix

Match between characters with regex.h


I'm trying to match strings like this: "labels": [{"name": "labelname" where labelname can contain any amount of letters, numbers or whitespaces. I tried "labels": \[\{"name": "(.*?)" ,which works in regex101.com but i dont get any matches using the posix regex.h. If i do "labels": \[\{"name": " it matches the string up to the fist "


Solution

  • Just do a class that select everything apart from the closing character, like that :

    "labels": \[\{"name": "([^"]*)"