目前我正在尝试找到具有以下条件的正则表达式:
Match: FOO_.* (valid if the string contains FOO_ at the beginning)
Don't Match: FOO_BAR (not valid if the string contains BAR)
Run Code Online (Sandbox Code Playgroud)
通常我会使用以下表达式:
FOO_(?!BAR)
Run Code Online (Sandbox Code Playgroud)
我的解决方案的问题是,我想在xml架构中使用它.与解析器一起使用会显示以下错误消息:
schema.xsd:50: element pattern: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}pattern': The value 'FOO_(?!BAR)' of the facet 'pattern' is not a valid regular expression.
WXS schema schema.xsd failed to compile
Run Code Online (Sandbox Code Playgroud)
是否有可读的;-)工作解决方案,或者只是在xml架构中是不可能的?
XML 架构不支持表达式的Lookaround部分。(?!BAR)
对于您的具体示例,以下表达式应该让您了解如何解决此限制:
FOO_([^B].*|B([^A].*|A([^R].*)?)?)?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1892 次 |
| 最近记录: |