Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2014
    Posts
    2

    Default Regular Expression Alignment Override Help

    Hi,

    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,
    James

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,609

    Default

    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. #3
    Join Date
    Jun 2014
    Posts
    2

    Default

    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]($_.name).substring(5) }
    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.
    Regex:
    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.

    Thanks,

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,609

    Default

    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. #5
    Join Date
    Jul 2014
    Posts
    4

    Default 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:

    [^_@]*=[^_@]*

    Somefile_2014-01-01.xyz (should be aligned with) Somefile.xyz
    Someotherfile@res2048.xyz (should be aligned with) SomeOtherfile.abc

    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. #6
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,609

    Default

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •