简体   繁体   English

使用正则表达式进行模式匹配 Python

[英]Pattern matching with regular expression Python

I have a sentence and want to check if a pattern exist or not.我有一个句子,想检查一个模式是否存在。 I am looking for pattern '...switch from...to...' is such a pattern exist return true otherwise false.我正在寻找模式'......从......切换到......'这样的模式是否存在返回真否则为假。 How can I write a regular expression for it in python?如何在 python 中为其编写正则表达式?

re.match('switch.*from.*to', txt)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM