I am trying to escape the following regex
(<t:Message>)[\s\S]*?(<\/t:Message>)
for using it in my ABAP source code.
All I got so far is the following:
(<t:Message>)[\\s\\S]\*?(<\/t:Message>)
But for any reason, it does not give the desired result.
Is there maybe any regex expert in here who could help me to escape this regex so that i can use it in ABAP? I would highly appreciate it.
答案 0 :(得分:2)
你的表达有两个主要问题,其中没有一个与转义有关。
还可以指定特殊字符\ w,\ u,\ l,\ d和\ s 内置[...]。使用特殊字符\ W,\ U,\ L,\ D和 不允许在集合内使用并引发异常 CX_SY_INVALID_REGEX。
(引自documentation) - 所以用其他内容替换它,例如.*
正则表达式r {n,m}?,r *?和r +?保留给未来 语言增强(非贪婪的行为),目前提高了 异常CX_SY_INVALID_REGEX。
(引自documentation) - 所以不要使用*?
(<t:Message>).*(</t:Message>)
至少在语法上是正确的 - 它是否符合您的要求是不明确的,因为您没有首先指定您需要的内容。