正则匹配两个特定字符,并获得第一个数字,然后是这些字符
如果用户输入VX为20 m/s VY为40 m/s VZ为60 m/s。
预期结果是来自输入的 Axis VX 和 20。
下面的代码还可以识别其他数字 40 和 40。 60也。
(VX)|(vx)|(Vx)|(vX)|[0-9]
If user inputs VX is 20 m/s VY is 40 m/s VZ is 60 m/s.
Expected results are the Axis VX and 20 from the input.
The code below also recognizes the other numbers 40 & 60 also.
(VX)|(vx)|(Vx)|(vX)|[0-9]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
添加
re.IGNORECASE
。请参阅正则表达式证明。说明
Python代码演示:
结果:
{'axis': 'VX', 'value': '20'}
Use
Add
re.IGNORECASE
. See regex proof.EXPLANATION
Python code demo:
Results:
{'axis': 'VX', 'value': '20'}