Visual Studio C++ Standard Regex get tag till whitespace

Visual Studio C++ Standard Regex get tag till whitespace

本文关键字:tag till whitespace get Regex Studio C++ Standard Visual      更新时间:2023-10-16

我有这个字符串:

LOWS 111150Z 38005KT 320V050

我需要 KT 标签 38005KT。KT 标签可以采用以下格式:

  • 18010KT
  • 35012G20KT
  • 00000KT
  • VRB16G28KT

我尝试使用以下正则表达式:

regex wind("[^\s].*KT");

但是我得到以下字符串:

LOWS 111150Z 38005KT

我做错了什么?

regex wind( "[0-9a-zA-Z]*KT" );

会给你所需的字符串。

这意味着在KT之前无限次0-9a-zA-Z

因此,不包括空格和其他所有内容。