0

I have a problem with SLRE library, I can't figure out how to stop grabbing everything after my match. Let's say I have a html output and somewhere in the middle of buffer there is line I want to parse

name="id" value="1a2b3c4d5e6f" />

Here is my regular expression

slre_compile(&test, "name=\"id\" value=\"(.*?)\" />")

I have read about greedy and non-greedy flags in other threads where people used to have similar problem as me, but in my case adding ? to the expression doesn't change anything. SLRE returns me match starting from 1a2b3c4d5e6f" /> and shows rest of the html page ending on </html> tag, just I don't know why. It is cutting the beginning of the html source but leaves everything after my expression. I have also tried following regex

slre_compile(&test, "^.*?name=\"id\" value=\"(.*?)\" />.*?$")

and some others, modified with greedy and non-reedy flags, which gave me same results. Does anyone know why SLRE can't stop at " /> and continues capturing characters till the source string ends?

JJJ
  • 32,902
  • 20
  • 89
  • 102

1 Answers1

0

it seems that SLRE does not understand non-greedy qualifiers and parses .*? instead as if it were (?:.*)?. However, in this case \"[^\"]*\" should work...

  • Unfortunately, it is also matching wanted value and rest of the page. Too bad, I though SLRE would be a perfect native crossplatform library but it seems it lacks some standard features or I'm just too stupid for this and I'm doing something completely wrong. – user2648790 Aug 03 '13 at 17:35