我如何看待一个单词?

问题描述 投票:0回答:1

在这个字符串a b-cd,我想应用这个正则表达式a b-c(?<=a)d

唯一的方法是像a b-c(?<=a b-c)d那样编写它,但我不想写它背后的整个正则表达式来应用它,只想看看这封信是否存在。

它的复杂版本:(?:[a-z] )?b c d e f(?:(?<=a ) alphas) https://regex101.com/r/gyT6ix/1

这可能吗?

Regex Lookaround Reference

regex lookbehind
1个回答
0
投票

在pcre中,你在评论中提到的qazxsw poi模式中的无限外观qazxsw poi不受支持。

匹配.*a b-c(?<=a.*)d的一个选项可能是使用看起来像[a-z] b c d e fa b c d e d alphas

if-then-else conditional

关于正则表达式

  • (?(?=regex)then|else) If条款 (?(?=a)\ba b c d e f alphas\b|[a-z] b c d e f) 肯定正确的正面是(? (?=a)匹配a并使用单词边界来防止a和alphas成为更大词的一部分
  • \ba b c d e f alphas\b
  • a b c d e f alphas匹配char a-z,然后是b c d e f)

看到|

© www.soinside.com 2019 - 2024. All rights reserved.