Announcement

Collapse
No announcement yet.

How to Multiline Replace?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to Multiline Replace?

    Hi! first of all congratulations on a wonderful product.

    I need BC to ignore the differences of the type:


    Code:
    		ASSERT_BREAK( blahblah );
    matches with

    Code:
    		if( !blahblah )
    			break;
    I've been trying to build a regex, but it seems multiline replacement is not allowed. Any pointers?

    And another thing, can we ignore line breaks while matching?
    i mean
    Code:
    abcd(ef,gh)
    should match
    Code:
    abcd
    (ef,
    gh)

  • #2
    Hello,

    Thanks for the examples. Unfortunately, BC3 does not support defining multi-line regular expressions. We do offer a Delimited grammar type, which can be defined to match one line and then an ending line, or the Lines type, which defines the first line and the next # lines after that.

    Linebreaks within a file are are still always important to the comparison, and are not ignore-able like a space or tab character. It is a non-trivial project, so while it is something we would like to tackle we do not have a timeframe for it.

    Our current workaround is to use a pre-process to normalize the line breaks and whitespace within a file. We have some examples for HTML, XML, and Java in our additional downloads for BC3's file formats (the Tidied variants). Are the above code snippets from Java?

    We do have a kb article that goes into detail on creating a custom file format using a custom external conversion process, here:
    http://www.scootersoftware.com/suppo...rnalconversion
    Aaron P Scooter Software

    Comment


    • #3
      Thanks for the information, I guess these workarounds will have to do for now.
      The code snippets were from C++ (they're from Adobe InDesign plugin development).
      I did follow your suggestion, and made a custom grammar type, where the
      regex
      Basic text category
      Code:
      ASSERT_.*\((.*)\);
      and
      Lines category
      Code:
      if\s*\(.*!(.*)\)
      and the next 1 line
      are identified as a custom grammar element named ASSERT, and unchecked this element in the list of important elements.

      I think I'll have to live with the line breaks for now.

      Also, I notice that we have an "Ignored" option in the right click, which is nice, but can we see which differences we ignored? Or is refreshing the only option to "undo" the ignore.
      Could we have an "Unimportant" option too, functioning similarly, which can mark the differences as unimportant, so that it can come up in the unimportant changes view?

      Comment


      • #4
        Ignored is a temporary method of selecting and ignoring text for just the current comparison. A refresh is the only way to clear it at this point.
        Update: Or you can toggle the Ignored state of a specific line by right clicking it again. The button will appear depressed in the context menu.

        We do not have a way to define unimportant text by selecting it in the comparison view, but I'll add it to our Customer Wishlist.
        Last edited by Aaron; 07-Jul-2011, 09:52 AM. Reason: Update: toggle Ignored on current line
        Aaron P Scooter Software

        Comment

        Working...
        X