Search code examples
regexregex-lookarounds

Regex Look Around Look Behind second , Look Ahead :


Given this string:

U7PG2,f09fc22cdb13,v4.0.80.10875: hostapd: ath1: STA f2:9f:c2:2d:db:13 DRIVER: Sead AUTH addr=cc:44:63:0c:25:64 status_code=0

I am trying to match v4.0.80.10875

If I use this look around statement: (?<=,)[^:]+(?=:) I match f09fc22cdb13,v4.0.80.10875

How can I tell it to look behind starting with the second "," in the string instead of the first?


Solution

  • If there is always the v in the strings, you should be able to use: (?<=,)(v[^:]+)