1

I have the string below (including line breaks) that is returned from a TFS 'Labels' command. I need to match against only the last build number (build.2).

How do I build a regex expression to do this?

Label                                                  Owner          Date      
---------------------------------------------------- -------------- ---------- 
ICSExternalGateway-04_MJR-ICSExternalGateway-build.0 Marchen, Keith 2/25/2015 
ICSExternalGateway-04_MJR-ICSExternalGateway-build.1 Marchen, Keith 2/25/2015
ICSExternalGateway-04_MJR-ICSExternalGateway-build.2 Marchen, Keith 2/25/2015 
hwnd
  • 69,796
  • 4
  • 95
  • 132

2 Answers2

1
build\.\d+(?![\s\S]*\bbuild\.\d+)

Try this.See demo.The lookahead will make sure there is no build ahead.

https://regex101.com/r/wU7sQ0/14

vks
  • 67,027
  • 10
  • 91
  • 124
0

You might try something like this. It works because ordinarily the wildcard character . does not match a newline:

(build.\d).*$

See Regex 101 Demo here for example and full explanation.

David Faber
  • 12,277
  • 2
  • 29
  • 40