I need to get all characters between a particular expression.
For example below is my sample document
This is a sample document.
$condtion
FIRST This text can be repeated many times until do while is called.
$endcondition
I need to get all the characters between $condtion and $endcondition But the while(matcher.find()) loop is getting called three times. Is it possible to handle this in regular expression. Only one condition must be satisfied. If that condition is satisfied the other conditions need not be called.
Your expression matches either
\\#if\\s*\\((.*?)\\)(.*?)\\#elseifor#elseor#endif. If you only want an or around the closing statement of the if block then you have to put it into a group like(?:elseif|else|endif).