Question

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!

Was it helpful?

Solution 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.

OTHER TIPS

I think you need this :

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top