0

I have the following RegEx:

val boldRegex = Regex("(?<!\\\\\\\\)@(.*)(?<!\\\\\\\\)@")

val boldRange = boldRegex.find("@test@ - this is just a test for @bold@ text")

When I run the above code in kotlin it extracts two groups with the following start/end position

0..38
5..33

What I actually need is: 0..5 and 33..38

Is there a way how to make this ungreedy (at last this is how I think it's called, I am using this website to test the RegEx: https://regex101.com/

The original RegEx in PHP looks like this: /(?<!\\\\)@(.*)(?<!\\\\)@/Us

Todd
  • 30,472
  • 11
  • 81
  • 89
Marian Pavel
  • 2,726
  • 8
  • 29
  • 65

0 Answers0