1
TYPE FruitEnum = ENUMERATION OF
    (APPLE
    ,BANANA
    ,PEACH);
END_TYPE;

I am stuck in regex problem. I want to match 'FruitEnum' and 'APPLE,BANANA,PEACH' but I can not get it. It is multi line and I couldn't find a pattern to match words. Can anyone help me about this match.

1
  • Can you show the regex you're currently using (and the code you're using to apply the regex)? Sep 9, 2014 at 8:39

1 Answer 1

0

This regex matches your example, with two groups, the first one would match FruitEnum and the other will match APPLE ,BANANA ,PEACH you only have to split the second group by , and trim the results to get APPLE, BANANA, PEACH separated:

/TYPE\s+(\w+)\s*=\s*ENUMERATION\s*OF\n\s*\(\s*((?:(?:\w+)(?:\s*,)?)*)\s*\)\s*;\s*END_TYPE;/gm

Here is a demo link

1
  • Thank you so much. You are really superb.
    – moleschott
    Sep 9, 2014 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.