I am practicing regular expressions in Kotlin and trying to start with a multiline string. However, I am not receiving any matches. I feel like I am doing it right and can't figure out the problem.
Test lines:
NAME="SLED"
VERSION="12-SP2"
VERSION_ID="12.2"
PRETTY_NAME="SUSE Linux Enterprise Desktop 12 SP2"
ID="sled"
ID_LIKE="suse"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sled:12:sp2"
I am trying to get the 15 and the 2 out of the PRETTY_NAME line. I want to make the substring SP2 optional in the case that it isn't always there. My code doesn't seem to be finding matches.
Regex:
private val myRegex = Regex("^PRETTY_NAME=\"SUSE Linux (?:Enterprise )?Desktop (\\d+) (?:SP(\\d+))?", setOf(RegexOption.MULTILINE))