正则表达式:避免在匹配单词前后捕获空格和引号

2024-06-07 18:05:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图捕捉单词,但只有当它是一个单独的单词而不是在文本中时。但它也捕获了我不需要的空格和引号。我用^\s和^\s尝试了几种变体,但无法正常工作

[^\w]它[^\w]-我是从这个开始的

我搜索的文本类似于:

capture: industry: IT 
capture: ${Txt_new}         IT 
capture: ${Industry}    Set '${Original}'=='Banking'    IT  Banking 
capture: 'industry' : 'IT', 
capture: 'industry':"IT", 
skip   : ${Txt_IT}          word
skip   : ITinthemiddleITofwordIT

My_Pattern.jpg


Tags: 文本txtnewit变体单词引号capture

热门问题