const regex = /public*[ ]enum*[ ]DynamicVocabularyName[ ]*{([\ \n\r\t]*([A-Z\_]*)[ ]*\,)*[\ \n\r\t]*/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('public*[ ]enum*[ ]DynamicVocabularyName[ ]*{([\\ \\n\\r\\t]*([A-Z\\_]*)[ ]*\\,)*[\\ \\n\\r\\t]*', '')
const str = `package com.motorolasolutions.vip.datatypes.names;
public enum DynamicVocabularyName {
ACTIVE_CRIMES_COUNT,
ACTIVE_CRIME_TYPE,
APPLICATION_NAME,
ARREST_COUNT,}
AREA_DESCRIPTION,
AREA_NAME,
BAD_PARAMETER_NAME,
BATTERY_PERCENT,
CAROWNER_PERSON_ADDRESS,
CAROWNER_PERSON_FULLNAME,
CAROWNER_PERSON_PHONE,
CRIME_DATE_DESCRIPTION,
CRIME_SUBTYPE,
}`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions