加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式排除单词(XML Schema风格)

发布时间:2020-12-14 02:29:16 所属栏目:百科 来源:网络整理
导读:目前我正在尝试找到具有以下条件的正则表达式: Match: FOO_.* (valid if the string contains FOO_ at the beginning)Don't Match: FOO_BAR (not valid if the string contains BAR) 通常我会使用以下表达式: FOO_(?!BAR) 我的解决方案的问题是,我想在xml
目前我正在尝试找到具有以下条件的正则表达式:
Match:          FOO_.* (valid if the string contains FOO_ at the beginning)
Don't Match:    FOO_BAR (not valid if the string contains BAR)

通常我会使用以下表达式:

FOO_(?!BAR)

我的解决方案的问题是,我想在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

是否有可读的;-)工作解决方案,或者只是在xml架构中是不可能的?

XML模式中不支持表达式的 Lookaround部分(?!BAR).

> http://www.regular-expressions.info/xml.html
> http://www.w3.org/TR/xmlschema-2/#regexs

对于您的具体示例,以下表达式应该让您了解如何解决此限制:

FOO_([^B].*|B([^A].*|A([^R].*)?)?)?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读