Dear All, I have a String template from which I need to get the list of #elseif blocks. For example the first #elseif block will be from
#elseif ( $variable2 )Some sample text after 1st ElseIf.
,second #elseif block is from #elseif($variable2)This text can be repeated many times until do while is called. SECOND ELSEIF
and so on. I'm using the following regex for this.
String regexElseIf="\\#elseif\\s*\\((.*?)\\)(.*?)(?:#elseif|#else|#endif)";
But it returns just one match, ie first #elseif block and not second. I need to get the second #elseif block also. Could you please help me to do that? Please find the below string template.
String template =
"This is a sample document."
+ "#if ( $variable1 )"
+ "FIRST This text can be repeated many times until do while is called."
+ "#elseif ( $variable2 )"
+ "Some sample text after 1st ElseIf."
+ "#elseif($variable2)"
+ "This text can be repeated many times until do while is called. SECOND ELSEIF"
+ "#else "
+ "sample else condition "
+ "#endif "
+ "Some sample text."
+ "This is the second sample document."
+ "#if ( $variable1 )"
+ "SECOND FIRST This text can be repeated many times until do while is called."
+ "#elseif ( $variable2 )"
+ "SECOND Some sample text after 1st ElseIf."
+ "#elseif($variable2)"
+ "SECOND This text can be repeated many times until do while is called. SECOND ELSEIF"
+ "#else " + "SECOND sample else condition " + "#endif "
+ "SECOND Some sample text.";