Regex to ignore decimal places in Beyond Compare

508 Views Asked by At

I am using Beyond Compare to compare two files and need help with a regex to ignore anything past 5 decimal places, eg -

1.0000000|

so the 6th figure onwards would be ignored seperated with |

I thought this would work \.\d\{5\}\| but it doesn't, any help would be appreciated

1

There are 1 best solutions below

0
On

If you have a pro version of bcompare you can set up a replacement (as described here: Beyond Compare - ignore certain text strings?).

Your Text to find: (\d+\.\d{5}).*

Your Replace with: $1

This will capture a number and its first five decimal places in a submatch ($1) and use that to replace the whole number and anything that comes after it (like | in your example). Be aware that numbers with less than five decimal digits are not matched. If you want to exclude other characters coming after the five digits, you need to change the part of the expression after the parentheses accordingly. E.g. if you only want to replace the number up to the | and not including it. your Text to find would be (\d+\.\d{5})\d*.

If you don't have a pro version, you can use a grammar element, (as described here: How do I make Beyond Compare ignore certain differences while comparing versions of Delphi Form Files).