Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Regex escaping help

Trying to get a regex working to take just the values out of the following:

enum('test', 'test1', 'test(2)', 'test3')

So that the result is something like: 'test', 'test1', 'test(2)', 'test3'

Currently trying to get it with this:

\((.*)\)$

But im having issues trying to get it propery escaped for zephir.

Provide please your code for parsing it. I'm try to help



141

may be

/test(([0-9\(\)])*)/


141

or

/test((\()*[0-9]*(\))*)*/


194
Accepted
answer
edited Feb '16

If you literally just want to get what's inside the enum (assuming that's just a string) then why even bother with a regex? Why not just use substr:

let str = "enum('test', 'test1', 'test(2)', 'test3')";
return substr(str, 5, -1);

results in you getting the string:

'test', 'test1', 'test(2)', 'test3'

Sorry never got any notifications until today.

Thanks Andrew, sometimes the most elegant solution is the simplest!!