Following this question it gives me just 1st match. I want to get all the matching into a string or a string array
This is my part of output from which I need to extract all Category
's
<Trace Enabled="false">
<ActiveCategories>
<Category>ENVIRONMENT</Category>
<Category>EXEC</Category>
<Category>EXTERNALS</Category>
<Category>FILESYSTEM</Category>
<Category>INPUT_DOC</Category>
<Category>INTERFACES</Category>
<Category>NETWORKING</Category>
<Category>OUTPUT_DOC</Category>
<Category>PREPROCESSOR_INPUT</Category>
<Category>REQUEST</Category>
<Category>SYSTEMRESOURCES</Category>
<Category>VIEWIO</Category>
<Category>ALL</Category>
</ActiveCategories>
<SeverityLevel>ERROR</SeverityLevel>
<MessageInfo>
<ProcessAndThreadIds>true</ProcessAndThreadIds>
<TimeStamp>true</TimeStamp>
</MessageInfo>
<TraceFile>
<FileName>CMDS_log.txt</FileName>
<MaxFileSize>1000000</MaxFileSize>
<RecyclingMethod>Restart</RecyclingMethod>
</TraceFile>
</Trace>
right now through the below code I am only able to fetch ENVIRONMENT
, I need to fetch all of the Category
's value
def regexFinder(String myInput,String myRegex)
{
String ResultString
Pattern regex
Matcher regexMatcher
regex = Pattern.compile(myRegex, Pattern.DOTALL);
regexMatcher = regex.matcher(myInput);
if (regexMatcher.find()) {
ResultString = regexMatcher.group();
}
}
tempResultString=regexFinder(ResultString,"(?<=<Category>)(?:(?!</Category>).)*")
csm.cmengine_category(tempResultString)
{ "${rs}" }
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…