0

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

Max
  • 11
  • 1
  • 3
  • Please post your code ([mcve]). You can use capturing groups to get portions of your matched string. Like in here https://stackoverflow.com/questions/41080116/how-do-i-match-exactly-a-partial-string-in-regexp-and-ignore-any-characters-befo?noredirect=1&lq=1 – Erwin Bolwidt Jul 12 '22 at 01:49
  • 1
    Can you use a [capturing group?](https://tio.run/##JYzLCsIwFET3@YpwRUhAC9VaQXAluBOELlXoNY8abNIQUxFLv72WOqthzmGqZhg8iidWilo0jhBjfRMiZYSOAW0j/FtQlfp4IJwQ3Tox2YzTbqKB7vb0bySn9hUPjfWmVqwEdsHl9ypvXZr3HEo@6eNrcg7GRc1gPntfHSxoSI7GySKOc1W0d4tRPFjp0Ko9bFBn6RbFepVJnYkcqK9RqEdTS1VyTvph@AE) – bobble bubble Jul 12 '22 at 02:10

2 Answers2

0

I used re.Submatch, which then worked out:

re := regexp.MustCompile(`"([a-z0-9]{16})`)
return re.FindStringSubmatch(string(req_text))[1]
Max
  • 11
  • 1
  • 3
-1

use substring to strip the ", or capture group

xie cui
  • 55
  • 5