简体   繁体   English

如何制作正则表达式模式? Python

[英]How to make a regex pattern? Python

...id|123|...

I need to get the id value.我需要获取 id 值。 I tried:我试过了:

print(re.search('id|(.*?)|', str)

but it printed a space但它打印了一个空格

"|" in regular expression means "either or"在正则表达式中的意思是“要么或”

"\|" searches for the character "|"搜索字符“|”

try 'id\|(.*?)\|'试试'id\|(.*?)\|'

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

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