This is the string I have:
text-center font-weight-bold rounded-0" name="5af417ac324df4c6" placeholder="Enter Video URL" aria-des...
I want to match 5af417ac324df4c6
, more exactly a 16 character long alphanumeric string. In the text there is other patterns that may get selected in the regex but are unwanted and to filter them out I use the parameter that the regex should only match characters after "
.
\"[a-z0-9]{16} or "[a-z0-9]{16}
Now comes the problem, if I do so, "
also gets selected in the matching strings
one solution I found: (?<=")[a-z0-9]{16}
, but (?<
is not supported in golang.
How can I achieve this
CodePudding user response:
I used re.Submatch, which then worked out:
re := regexp.MustCompile(`"([a-z0-9]{16})`)
return re.FindStringSubmatch(string(req_text))[1]
CodePudding user response:
use substring to strip the ", or capture group