No announcement yet.

Why BC4 RegExp doesn't understands '\n' ?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Why BC4 RegExp doesn't understands '\n' ?

    Just to start with an example
    I like text like this
    ATA Interface\0BIOS Services\0DOS Services\0DOS ASPI
    to be changed into this:
    ATA Interface
    BIOS Services
    DOS Services
    so I use hit ctrl+h to bring up replace and there enabled RegExp to
    look for: \\0 and
    replace with: \n

    But \n is just replaced by '\n' and not with s new line as I intended.
    ATA Interface\nBIOS Services\nDOS Services\nDOS ASPI
    Well when I do
    replace with: \x0d\x0a
    it works.

    However I'm a little a fan of BC and find it a little odd that BC4 RegExp somehow doesn't have '\n' defined.
    Its a very common Metachar and its a little irritating if it is not working.
    BC4 knows '\t' and '\0'...
    -> Even if '\0' is not mentioned in the BC help file(<- I only checked the german ones) about regulary expressions .

    ...but why not '\n' ? (...and not to forget '\r' what is carrier return)
    Is there a special reason why this is missing or disabled?
    Last edited by Djamana; 01-Feb-2018, 09:39 PM.

  • #2

    All of BC4's various regular expression support can vary a little, a subset of the full spectrum of Regular Expressions available, and only Finds on the current line. The Replace With section only offers Tagged Expression support (listed in the dropdowns next to either the Find or Replace textboxes), but since the library supports \x and we don't limit that support, it (somewhat unintentionally) supports inserting the newline break. Expanding that support is something on our wishlist.
    Aaron P Scooter Software


    • #3
      Beyond Compare 4.2.5 now supports \n and \r in the Replace field for Find & Replace when using regular expressions.
      Last edited by Chris; 19-Jun-2018, 06:39 PM. Reason: Clarify \n and \r only supported in replace field.
      Chris K Scooter Software


      • #4
        is supporting \n in the replacement of Rules/unimportant also planned?

        Actual I'm facing a not happening replacement for "\n".

        My use case is:
        This is a test to identify further required test steps.
        This is a test
        to identify further required test

        A rule for "right" side to replace regEx pattern "test\n" with "test " does not work.
        In hexView I've already checked the line limiters, and they are of single value 0x0A. A cross check with the regular replace-function works well and detects/replaces the limiters properly. a support of \n-replacement in rules also planned, or is there any other reason for my not working replacement?

        Thanks for your answer in previous! Regards,


        • #5

          Expanding and handling multi-line handling is something on our wishlist, but isn't an quick enhancement given BC's emphasis on a line by line comparison. It's something still on our wishlist, but is not likely a project we'd be able to tackle soon.
          Aaron P Scooter Software