# Rex: multiline comment

**URL:** <https://www.ruby-forum.com/t/rex-multiline-comment/87613>\
**Category:** Ruby\
**Created:** [March 4, 2007, 2:30pm UTC](https://www.ruby-forum.com/t/rex-multiline-comment/87613 "2007-03-04T14:30:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harry\_van\_Stedum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/73ab20/32.png) [@Harry\_van\_Stedum](https://www.ruby-forum.com/u/Harry_van_Stedum)\
**Post date:** [March 4, 2007, 2:30pm UTC](https://www.ruby-forum.com/t/rex-multiline-comment/87613/1 "2007-03-04T14:30:58Z")

</div>

Hi all,  
does anybody using Rex know how to deal with multline comments (of the  
kind “/\* … \*/”)?  
In the Rex-docs I can find this:

macro  
REMIN /\*  
REMOUT \*/

rule  
{REMIN} { state = :REM ; [:REM\_IN,  
text] }  
:REM {REMOUT} { state = nil ; [:REM\_OUT, text] }  
:REM (.+)(?={REMOUT}) { [:COMMENT, text] }

I changed the rules like this, as I don’t want to propagate comments  
to the parser:

rule  
{REMIN} { state = :REM ; nil }  
:REM {REMOUT} { state = nil ; nil }  
:REM (.+)(?={REMOUT})

I have no idea, nor can I find anywhere, the meaning of “?=” in the  
last line, however it seems to work for 1-line comments; it breaks on  
multiline comments though. It expands to “(text = ss.scan(/(.+)(?=\*  
/)/))” in the generated ruby-code, where ss is a StringScanner  
object.

The “/\*” is found/matched, after that the lexer fails with  
(JavaLexer::ScanError); it seems the (.+) cannot be matched.

Thanks, Harry
