Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 无法为字符串生成正则表达式_Regex - Fatal编程技术网

Regex 无法为字符串生成正则表达式

Regex 无法为字符串生成正则表达式,regex,Regex,我有一个字符串abc-[| 123 | 243 |]-xyz-[| 432 | 567 |],我想生成一个与特定字符串匹配的正则表达式 应根据以下示例和特定结果测试正则表达式 实验一:abc-[| 123 | 234 |]-xyz-[| 432 | 567 |](123出现在[| 123 | 243 |]中) 结果:匹配 实验二:xyz-[| 123 | 243 |]-abc-[| 432 | 567 |](abc和xyz的顺序互换) 结果:不匹配 实验3:abc-[| 243 | 563 |]

我有一个字符串
abc-[| 123 | 243 |]-xyz-[| 432 | 567 |]
,我想生成一个与特定字符串匹配的正则表达式

应根据以下示例和特定结果测试正则表达式

实验一:
abc-[| 123 | 234 |]-xyz-[| 432 | 567 |]
123
出现在
[| 123 | 243 |]
中)

结果:匹配

实验二:
xyz-[| 123 | 243 |]-abc-[| 432 | 567 |]
(abc和
xyz的顺序互换)

结果:不匹配

实验3:
abc-[| 243 | 563 |]-xyz-[| 432 | 567 |]
243
432
存在)

结果:匹配

实验4:
xyz-[| 143 | 434 |]-abc-[| 432 | 999 |]
[| 148 | 434 |]
中的任何数字都不匹配

结果:不匹配

我尝试创建一个正则表达式,但它只在实际情况下有效,在其他情况下无效

abc-\[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

^abc-\[\\\\\\\(?:123 | 243)\\\\d+\\\\\]-xyz-\[\\\\\\\\\\\\\\\\\d+\\\\]$

详细信息

  • ^
    -字符串的开头
  • abc-\[\\\\\\\\
    -
    abc-[\\\\\\\\\\\\\\\\\
  • (?:123 | 243)
    -要么
    123
    要么
    243
  • \\\\\
    -a
    \
  • \d+
    -1+位
  • \\\\]-xyz-\[\\\\\\\\\\\\\\\\\\\\\\[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/code>-a
    \\\\\\\\\\\\\
  • \d+
    -1+位
  • \\\]
    -a
    \\]
    文本
  • $
    -字符串结尾

您能展示一下正则表达式吗?那么,您的正则表达式模式是什么?我曾在问题的底部提到过它,但仍然,它在这里是abc-[12412412?12412??1241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241241244124124124124124124124124;243124W:我怀疑我怀疑ReReReRebebebebebebe。我怀疑,我怀疑ReReReReReReReReReReReReRebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebe我们能够得到精确的是能够得到确切的。我怀疑正则。我怀疑Rebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebe;\ d+\\\\]*]-xyz-\[\\\\\\\\\\\\\\\\\\\\\\]$
,请参阅