No announcement yet.

Regular Expression Alignment Override Help

  • Filter
  • Time
  • Show
Clear All
new posts

  • Regular Expression Alignment Override Help


    I have the following:

    0001 Somthing.xml versus 0009 Somthing.xml
    0002 JoeBlogs.xml versus 0005 JoeBlogs.xml

    Basically I need to mask the first 4 characters of each filename

    Although I can match the left with ([^0-9]{4})

    I would like to then say *$1 on the right. I don't think it works like this, could someone help me with a work around. I have hundreds of files to compare and the numbering on the front is not always ==

    Kind regards,

  • #2
    Hello J_D,

    Sorry, our Regular Expression for Alignment Overrides does not support this type of mask. You can mask the equal characters to help with a change like this:
    0001 Something.xml vs 0009 Something.xml
    0001 Joe.xml vs. 0009 Joe.xml
    0001 etc vs 0009 etc

    You could then define a RegEx or Dos mask equivalent to align this type of change: 0001 filename = 0009 filename.

    We do not currently support a method to ignore specific arbitrary characters. The Replace With only supports tagged expressions ($1 referencing a match) or explicit text.
    Aaron P Scooter Software


    • #3
      Thanks for the reply.

      If you have a Product Backlog can I request this is put forward for review, in my work scenario it would be a big win.

      For those that might be faced with a similar situation. I have worked round as follows:
      Run the following powershell command to strip X (in my case 5) characters from the file name.
      gci *.xml | rename-item -newname { [string]($ }
      This assume the files are .xml

      Then in BeyondCompare I ran the stripped folder against my target folder (LEFT hand side) and then used the following Regex to Align correctly. I need to leave my Target folder with the Numbers as they functionally impact the system that consumes them. Otherwise the obvious solution would have been to strip the numbers entirely on both side before I even get to BC.
      Right: (.{5})(.*)
      Left: $2

      This successfully aligns my left (Target) with my Right (Source)

      0001 File1.xml | File1.xml
      0005 File2.xml | File2.xml
      0002 File3.xml | File3.xml

      Not ideal but does get round this issue.



      • #4
        Thanks for the feedback. I've added these notes to our Wishlist. And that is a good idea for a workaround if you are able to rename some of your files.
        Aaron P Scooter Software


        • #5
          Alignment with partial name

          While I can understand the above restriction with respect to aligning with variable characters like $1 (although I think it would be a very useful concept), I do not understand at all why I can't even truncate the front of a name at a certain position.

          Unfortunately the I do not have the choice to perform a rename in a copied instance of the files, the amount of data is prohibitive. My target objective is to reduce the number of duplicates, not to duplicate!

          The trouble appears to be that instead of defining what should not be aligned, you can't say what to use for an alignment. I tried the following regexes, trying to align up to the first _ or @ in a name, and ignore the rest of the name:


 (should be aligned with)
 (should be aligned with)

          I also tried, without success, this:
          and further variants, but it seems to be impossible to ignore trailing characters (as well as the $1 problem discussed so far).

          May I suggest adding features like these?


          • #6
            The difference in defining the difference characters vs. the equal characters is exactly the limitation you are running into. The Alignment Overrides feature does not support the type of definition you are looking for, but it is something on our Wishlist.

            We should be able to handle specifically trailing characters, but only if the 'longer' side is on the Left. You can then use a similar method as the rename workaround above, where the longer side is defined and has () around the matching section, then the trailing characters can be left out of the match below. The Swap Sides command in the Folder Compare can be useful for helping view the longer matches on the Left.
            Aaron P Scooter Software