Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想写一个可以匹配以下字符串的正则表达式:
OFF ON String Valve
我在想写^(?<arrivingString>[a-zA-Z]{?})$。
^(?<arrivingString>[a-zA-Z]{?})$
现在我不知道在大括号内写什么,因为到达字符串的值是不同的且随机的。
谢谢
^(?<arrivingString>(OFF|ON|String|Valve)).*
这匹配仅提供的这 4 个单词:
如果它以这 4 个字符串中的任何一个开头,则此 Regex 将完整匹配每一行。捕获的组arrivingString将包含找到的四个单词中的任何一个。
arrivingString