I'm trying to extract messages from following type of strings,

Error_Message('The value 1,2 and 3 that you have entered is invalid.');

using the following regular expression,

\s*(\w+):\s*(?:'\s*(?:\|\S*)'\s*|[^'])+'

Could be tested here

But the problem is that this fails in certain scenarios such as,

General_Message('Sample message value :p you have '||CHAR(10)||'entered is invalid.', FunctionY('xyz', param2) );

General_Message(' The percent may not be negative.',FunctionZ('xyz', parameter2));

Need support from you guys to fix this.

Thanks in advance!

有帮助吗?

解决方案 2

Will it always be Message before the open bracket? if so:

(?<=Message\()'[^.]+

if not:

^.*?('[^']+')

and the first capture group, see here.

EDIT: for the whole message:

^.*?('[^.]*.')

See here for example.

其他提示

I think you need this :

(?<=General_Message\()'[^.]+

demo here : http://regex101.com/r/fF0iV1

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top