oh sorry, this is my complete problem. I have the next text with this 3 sections that starts with the "rule" word and ends with the "end" word. And i must build a regular expression able to detect all of them separatly. This is an example, the rule-end sections can be more or less, of course
complete text:
package com.domain.test;
import com.domain.test.OtherExampleCode
import com.domain.test.SomeExampleCode
rule "MA30"
when
$ma30 : Double() from accumulate( ClosePrice( $value : open ) over window:time( 30ms ), average( $value ) )
then
results.setMa30( 3000 );
end
rule "MA20"
when
$ma20 : Double() from accumulate( ClosePrice( $value : open ) over window:time( 20ms ), average( $value ) )
then
results.setMa20( $ma20 );
Integer other = $ma20 * 33;
System.out.println("result: " + other);
end
rule "MA23"
when
$ma23 : Double() from accumulate( ClosePrice( $value : open ) over window:time( 23ms ), average( $value ) )
then
System.out.println("some text");
results.setMa23( $ma20 );
end
Expected output:
group 1:
rule "MA30"
when
$ma30 : Double() from accumulate( ClosePrice( $value : open ) over window:time( 30ms ), average( $value ) )
then
results.setMa30( 3000 );
end
group 2:
rule "MA20"
when
$ma20 : Double() from accumulate( ClosePrice( $value : open ) over window:time( 20ms ), average( $value ) )
then
results.setMa20( $ma20 );
Integer other = $ma20 * 33;
System.out.println("result: " + other);
end
group 3:
rule "MA23"
when
$ma23 : Double() from accumulate( ClosePrice( $value : open ) over window:time( 23ms ), average( $value ) )
then
System.out.println("some text");
results.setMa23( $ma20 );
end
Thanks