首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在apache regex中对特定单词使用正向先行

如何在apache regex中对特定单词使用正向先行
EN

Stack Overflow用户
提问于 2014-06-03 12:47:00
回答 1查看 520关注 0票数 0

如何在apache regex中对特定单词使用正向先行。

示例:

在java正则表达式中,我有以下正则表达式^(?=.*\bLOCAL\sSERVICE\b)

apache regex中等效的regex是什么?apache regex中是否有任何与?=等效的正向先行检查?

EN

回答 1

Stack Overflow用户

发布于 2014-06-03 12:50:20

简而言之:使用PCRE regex引擎,这是目前功能最齐全的引擎之一。您可以使用在Java.中使用的相同的先行

有一些细微的差异,但它们对您的模式不应该有什么影响。

参考:Java和PCRE中模式的逐个令牌比较

  • 断言字符串开头的位置可以匹配下面的正则表达式,从该位置开始(正前视) (?=.*\bLOCAL\sSERVICE\b)
    • Java8以不同的方式解释此部分.*
      • 匹配任何不是换行符的单个字符(换行符、回车符、下一行、行分隔符、段落分隔符) .*
        • 在零次和无限次之间尽可能多次地返回(贪婪) *

代码语言:javascript
运行
复制
- PCRE 8.34–8.35 UTF-32 interprets this part differently `.*` 
    - Match any single character that is NOT a line break character (line feed) `.*` 
        - Between zero and unlimited times, as many times as possible, giving back as needed (greedy) `*`

代码语言:javascript
运行
复制
- Java 8: Assert position at a word boundary (position preceded or followed—but not both—by a Unicode letter, digit, or underscore) `\b`
- PCRE 8.34–8.35 UTF-32: Assert position at a word boundary (position preceded or followed—but not both—by an ASCII letter, digit, or underscore) `\b`
- Match the character string “LOCAL” literally (case sensitive) `LOCAL`
- Match a single character that is a “whitespace character” (ASCII space, tab, line feed, carriage return, vertical tab, form feed) `\s`
- Match the character string “SERVICE” literally (case sensitive) `SERVICE`
- Java 8: Assert position at a word boundary (position preceded or followed—but not both—by a Unicode letter, digit, or underscore) `\b`
- PCRE 8.34–8.35 UTF-32: Assert position at a word boundary (position preceded or followed—but not both—by an ASCII letter, digit, or underscore) `\b`

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24007309

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档