REGEXP:  In-line comments

I am building a formatter for MU* game coding (MUSHes, if you are familiar). In short, the program takes this:
&TEST me=$test:     
  [setq(0,#2)];
## Test Comment
  @switch/first
    [ifelse(1,1,0)]  ## Inline test comment.
  =
  0,
##          Another Comment with more spaces
      @pemit %#=%ch%crERROR:%cn Uhoh!
  1,
      @pemit %#=%ch%cgGAME:%cn Good!
    }parses through it, and produces a single line:
&TEST me=$test:[setq(0,#2)];@switch/first [ifelse(1,1,0)]=0,{@pemit
%#=%ch%crERROR:%cn Uhoh!},1,{@pemit %#=%ch%cgGAME:%cn Good!}NOTE: The first step is pulling all of the comments (This is where I am having trouble), I will work on removing newlines and spaces, et al, after I overcome this hurdle.
The problem I am running into is that the '## COMMENT' regexp I am trying to build is not working. I am currently using \#\#[(\s+)(\S+)]+$, but this is ending up with everything after the [setq()] function being axed. All I want to do (at this first point) is remove everything from '##' to the end of that input line.
In my readings, I am finding that the way Java parses MULTI-LINE strings is very different from other languages, such as Perl. Java wants to match the /entire/ string, which I do not want.
How do I flag the pattern object to say 'Hey, only apply/match this pattern in /each line/ of this multi-line string.' ?

It looks like you're trying to use square brackets for grouping, which is wrong. Square brackets define a character class, within which most characters lose any special meanings they normally have, but class shorthands like \s and \S still work. So you've created a character class that matches parentheses, plus signs, any whitespace character, and anything that's not a whitespace character. In other words, it matches everything.
The regex you need is actually very simple:  Pattern commentPattern = Pattern.compile("##.*");I should also mention that the '$' anchor normally doesn't match line ends; you have to compile the Pattern with the MULTILINE flag set to make it do that. It wouldn't make a difference with your regex, though, since the [\s\S]+ will always gobble up the rest of the input anyway.

Similar Messages

  • AR Invoice Print - Print on Preprinted stationary with Line comments & more

    Hi All,
    I have a requirement to print a report in XMLP for AR Invoice Print.
    Requirement
    For Template Body - Line Items
    Line 1-------------------------------------------------------------------------------------
    Line 2-------------------------------------------------------------------------------------
    Line 3-------------------------------------------------------------------------------------
    ----------------------<LINE COMMENT>----------------------This will be line :4
    Line 5-------------------------------------------------------------------------------------
    Line 6-------------------------------------------------------------------------------------
    Line 7-------------------------------------------------------------------------------------
    ----------------------<LINE COMMENT WITH 2 LINES - So the 2nd line will wrap >-----This will be line :8 and 9
    Line 10-------------------------------------------------------------------------------------
    1. Display 10 lines per page
    2. If there are Line comments for the particular line description then print the line comment in the next line as shown above - So it starts from the begin of the first column and prints till the last column of that particular row
    3. If there are more than say 100-200 characters of text then the Line comments will wrap to the next line
    4. Maintain the size of the frame size (or display 10 lines per page)
    I have already implemented 10 lines per page, which is not at all any issue, but in case there are line comments then it does not count that row. Also if the line comments wrap to 2 or more lines then it is still more complicated.
    Does anyone have a solution to this issue. Also, if any of you have implemented this earlier, kindly let me know if you can share the template for reference.
    Thanks and appreciate all your suggestions.

    Hi,
    Was anybody able to an answer to this issue? I have the same requirement where I have multiple subgroups under main group. To print a fixed number of lines in the template is causing an issue.
    Thanks,
    Sandeep

  • Multi-line commenting

    Okay, so we've been having a little side argument at work for a few weeks now.
    The premise is, is it best practice to use multi-line C-style comments in Java code any more?
    The arguments tend to vary from saying that the following is ugly:
    // This is a multiline comment.
    // Isn't it pretty?
    //To the above being better than the following:
    * This is a multiline comment.
    * Isn't it pretty?
    */The latter argument tends to be based around the fact that multi-line comments "cancel each other out" for want of a better description. (I.e. you cant have nested C-style comments because the first close will close both) e.g.
    *int x = 200;
    *int y = 300;
    * *A comment
    *int a = 1;
    //Oh no- the above can't work!
    String s = "abc";I'm interested to know what the forums think of this.

    meacod wrote:
    masijade. wrote:
    You do realise though, that those leading *'s on each line in those C style comments are not necessary, right? ;-)Oh, of course. I just did that to illustrate the point a bit more clearly.Okay, I thought you did, but I have known a few people who didn't. ;-)
    I suppose another item that enters into this is whether you believe in commenting out code or not. I'm firmly of the belief that you should never commit whole swathes of commented-out code; it either exists and will work, or doesn't work and should therefore be taken out. Others of course feel differently...True, but sometimes you're just trying things and may change it back, in which case it's easier to just comment out one portion. Not that that should be more than temporary, of course. ;-)

  • JavaScript editor single line comment bug

    Where a singe line comment (//) include Turkish specific character (ğüşıöçĞÜŞİöç) editor shows unexpected token "UNEXPECTED_CHARACTER" error.
    But multi line comment (/**/) work correct.

    Hi,
    This has been fixed and will be available when the next build of JDeveloper 11g is placed on OTN.
    Thanks
    Ashwin

  • How to enter a multi-line comment in the Info editor?

    When entering comments for a song (in Command-I Info), is there an easy way to break the comment into multiple lines?
    I realize that I can copy-and-paste from a text editor, but (a) it's cumbersome (b) the line breaks don't show in the Comments column, so it's pretty ugly.
    Any suggestions?

    hi,
    hope it helps.
    create a fieldcatalogue.
    and give output length as 100 characters for the field in which u have multiline data.
    plz reward if useful.
    regards,
    srishti

  • In SQL Editor Window '--' at end of line comments out the next line

    Hello,
    when I run a query with '--' at the end of a line, the next line seems to be commented out:
    select * from v$parameter
    where 1 = 1
    -- and value = '0' ------------
    and value LIKE 'AMERICA%'
    this will result in showing all v$parameter records!
    When I change the last character, it works properly.
    select * from v$parameter
    where 1 = 1
    -- and value = '0' ------------ X
    and value LIKE 'AMERICA%'
    Regards,
    sknoess

    Bugged in EA2: Bug with '--' inside string
    K.

  • How to customizing single line comment

    Because of the restriction of our dsl language we cannot use SL_COMMENT terminal directly. We have own rule of "Comment" which is defined as a parser rule.
    // '..' is the identifier of our comment rule just like '//'
    Comment:
    '.' '.' (ID|INT|ANY_OTHER)*
    Now we have a problem:
    How can we insert/remove '..' with standard shortcut "Ctrl+/" ? Could we reimplement this feature anywhere in XText ?
    Has anybody any idea for it?

    Christian Dietrich wrote on Tue, 30 June 2015 12:32org.eclipse.xtext.ui.editor.toggleComments.ISingleLineCommentHelper.getDefaultPrefixes(ISourceViewer, String)
    Thanks for your useful hints. It helps me so much.
    But still a problem could not be solved. We have following grammar:
    // this is not comment
    ..!meta foo bar
    //following 2 line are comments
    ..!foo bar
    ..foo bar
    It means that every line which begins with '..' is a comment except that begins with '..!meta'.
    Now the problem is:
    When I type 'ctrl+/' at line '..!meta foo bar', it removes the prefix '..'. But I want to insert '..' before '..!meta'.
    How can I do it? Should I reimplement ToggleSLCommentAction? If yes, where is this Action called or injected?

  • A/P invoice line comments (or ref) to Journal Entry

    Scenario:
    a/p invoice, service type is created.
    Several lines, but may post to same GL account.
    Description field contains description that should also be visible on Journal entry, so on screen GL reports show the descriptive texts.
    Reference is by document, not by line. The same goes for journal remark.
    Any ideas on how to do this?

    Hi......
    I guess there is no chance to display as you are asking.
    You have to create your own Query Report for this.....
    Regards,
    Rahul

  • Multiple line comments

    I am working with a module pool programming
    I need to create a input field which will have wide text box of length 100.
    if any data coming to that field, it has to place line by line in the same text box(as paragraph).
    can anyone help me in this regard?
    thanks in advance

    Hi friend,
    I think u have to use 'Table Control' not 'Input/Output field' for getting paragraph.
    Select  'Table Control'  in screen layout with length 100.
    Thanks..

  • Business Objects and Adobe / Application to add comments per report line

    Good day,
    Is it possible to use a Business Objects report output and post it into Adobe forms? We would like to use a report output and allow users to comment per report line - online - or is there any other application in Business Objects which will make this possible
    For Example:
    Report Line Comment
    Sales 9999.9999 ______________________________________
    Expenses 99999.99 ______________________________________
    Thank you.

    Hi,
    I would suggest you post your question into the corresponding BusinessObjects client tool forum.
    Ingo

  • How to put a comment(remark) into a certain line in ACL on L3 switch

    hello all,
    am I correct that for comments in access lists on L3 switches it is provided only so limited functionality, that it is possible only to put a remark at the end of existing rules list and no way to put a comment into a defined line, but only reapply the whole access list?!
    (config-ext-nacl)#remark ?
      LINE  Comment up to 100 characters
      <cr>
    Maybe other commands exist or special applications that can help with such important matter ?

    You're correct. Remark entries will be added in the order that you enter them, but can't be inserted with a sequence number. Any time I've needed to make changes to ACL remarks, the ACL has had to be deleted and re-created with the new entries.

  • How to add a comment in a php file which has html code

    Hi
    I have a html file which I renamed .php after adding a form. I discovered that the html comment text I was using - <!--this is a comment --> - was affecting how the page rendered, particularly in IE9.
    My question is, now that it is a php file do I need to change all the comments syntax? I started to do it using the "apply comment" button in CS5 i.e. syntax: <?php /*?>form<?php */?>.
    Is this the right way to do it? It gives "php" icons in design view but appears to render ok.
    Thanks

    PHP comments:
    <?php
    //This is a comment
    This is
    a php comment
    block
    ?>
    Use PHP comments inside PHP scripts/code.
    HTML comments:
    <!--comment-->
    <!--this is
    an html comment
    block-->
    Use HTML comments inside HTML code.
    CSS Comments:
         /*comment*/
         /*this is
         a css comment
         block*/
    Use CSS comments inside CSS code (either embedded or external).
    JavaScript comments:
    //this is a single line comment
    //this is another single line comment
    /*this is a multi-line
    javascript
    comment
    Use JavaScript comments inside JavaScript code (either embedded or external).
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Issue printing combined document with comment summary.

    I am having an issue generating the correct output for printing a comment summary with connector lines.  I started off with three duplicate documents, all of which had been commented on by different individuals.  The documents and comments were combined and I attempted to print the comment summary with connector lines.  I noticed that at the bottom of the first page, where there should have been a comment, there was only the name of the person who had commented and then the standard line "Comments continued on next page" but the person's comment was not there on page 2.  Its as if only their response is being cut off but you can still see their name, along with the date and time of the comment.
    I sent the issue over to someone I know who has Adobe Acrobat Pro X and they did not have the same issue.  I am not able to upgrade to V.X yet so if there's anyway to correct this or if I am doing something wrong, could someone please respond and let me know?  I combine documents and print with comment summaries on a regular basis.
    Thank you

    Hi Alejandro,
    thanks a lot for your reply, but I am afraid this does not have anything to do with that.
    I have checked the option that you mention and it was checked. Besides, I am using now Web Intelligence Rich Client, so that option should not be a problem.
    I don't really know what it is, it seems to be a bug or maybe the alert are not supposed to be printed.
    I would appreciate any idea that could help.
    Thanks a lot

  • How to give comments in .properties file?

    hi
    can any one tell how to give commens in .properties file
    any thing after first space will be treated as key value pair
    thanks in advance
    bye

    hi
    can any one tell how to give commens in .properties
    fileAny line that begins with a # is a comment in a properties file. These are single line comments.
    any thing after first space will be treated as key
    value pairEh?
    thanks in advance
    byePreemptive welcome.

  • EUL Export errors - comments in Custom Folders

    In the spirit of sharing.
    I recently had some major problems releasing a Discoverer EUL through our database release process, using the EUL Export functionality (i.e. creating an .eex file).
    I have a large complex Custom Folder in the EUL, comprised of 14 large unioned select statements.
    The EUL would seem to import OK into the new database, but a Workbook based on the Custom Folder continually came up with an item dependancy error.
    We traced the problem back to the Custom Folder, which was invalid in the Admin Tool, and therefore not visible to the EUL Users - with a workbook based on the offending Custom Folder.
    The moral of the story is DO NOT put single line comments "--" in Discoverer Custom Folder SQL queries - especially large queries. The EUL Export process will unformat your queries, and the single line comments will end up inside the valid SQL - which will invalidate it.
    Only use block comments "/* Comment */" in your Custom Folders.
    Hope this helps someone else save some time.

    Just a note to thank u for this post. This is one of the answers I was searching for today and now I see the light!

Maybe you are looking for