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
  • 28,544
  • 10
  • 77
  • 83
Marian Pavel
  • 2,486
  • 6
  • 26
  • 54

0 Answers0