-1

this regex give string between two string "(?<='v')(.*)(?='d')",

but i have some problem sometime with regex,

like this ex " 'v'string1d'd'string2'd' ",

if use this regex he give me this result : string1d'd'string2

i want only get the string1 there any way to fix it

C.Nivs
  • 12,353
  • 2
  • 19
  • 44
lou cjcj
  • 33
  • 5
  • You can make the regex non-greedy: `"(?<='v')(.*?)(?='d')"` but it will give you the string `string1d` not `string1`. – Mark Apr 13 '20 at 22:19

1 Answers1

0

Regexp matches are by default greedy, if you want the minimum match (laziness) this should work: "(?<='v')(.*?)(?='d')"

see: "Laziness Instead of Greediness" in https://www.regular-expressions.info/repeat.html

James Powis
  • 609
  • 4
  • 16