正则表达式帮助 [英] Regex Help
问题描述
全部,
如何描述由任意数量的字符组成的字符串,
是可选的(但在发生时是唯一的)end-of -line表达式''/''?如果可能,使用
组,如(?< sentence>。*(?< eos> [^ \\] [\\] {1} $)? )
我说我的泰勒是/作为输入;我想要''句子''
和''eos'来匹配。
现在,如果我有''我的泰勒是// ''或'''我的泰勒是/'',''句子''应该
匹配,但不是''eos''。换句话说,''eos''应该只在它出现一次时才会匹配,最后一次出现在字符串中。
我试过在其中嵌套eos句子,并置它们,删除
量词,删除字符串结束断言......似乎没有什么好看的。
令人满意地工作。
感谢您的帮助,
Jules
)?)"
我说我的泰勒是/作为输入;我想要''句子''
和''eos'来匹配。
现在,如果我有''我的泰勒是// ''或'''我的泰勒是/'',''句子''应该
匹配,但不是''eos''。换句话说,''eos''应该只在它出现一次时才会匹配,最后一次出现在字符串中。
我试过在其中嵌套eos句子,并置它们,删除
量词,删除字符串结束断言......似乎没有什么好看的。
令人满意地工作。
感谢您的帮助,
Jules
对不起,拼写错误:请阅读(?< sentence> 。*(?< eos> [^ \\] [\\] {1}
)?)"
as" ;(小于?句子GT; *(小于?EOS> [^ /] [/] {1}
All,
how do I describe a string consisting of any number of characters, with
an optional (but unique when occuring) end-of-line expression ''/''? With
groups if possible, as in "(?<sentence>.*(?<eos>[^\\][\\]{1}$)?)"
Say I have the phrase ''My Taylor is /'' as input; I''d like ''sentence''
and ''eos'' to match.
Now if I have ''My Taylor is //'' or ''My Taylor is / '', ''sentence'' should
match, but not ''eos''. In other words, ''eos'' should match only when it
occurs once, and last, in the string.
I have tried nesting eos within sentence, juxtaposing them, removing
quantifiers, removing the end-of-string assertion... nothing seems to
work satisfactorily.
Thanks for any help,
Jules
)?)"
Say I have the phrase ''My Taylor is /'' as input; I''d like ''sentence''
and ''eos'' to match.
Now if I have ''My Taylor is //'' or ''My Taylor is / '', ''sentence'' should
match, but not ''eos''. In other words, ''eos'' should match only when it
occurs once, and last, in the string.
I have tried nesting eos within sentence, juxtaposing them, removing
quantifiers, removing the end-of-string assertion... nothing seems to
work satisfactorily.
Thanks for any help,
Jules
Sorry, misspelling: please read "(?<sentence>.*(?<eos>[^\\][\\]{1}
)?)"
as "(?<sentence>.*(?<eos>[^/][/]{1}
这篇关于正则表达式帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!