0

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

buddemat
  • 4,552
  • 14
  • 29
  • 49
fatbij
  • 7
  • 2
  • 2
    Why not just `\.\d{5}` then? – Wiktor Stribiżew Oct 21 '20 at 07:48
  • 1
    Please clarify what you mean by "the 6th figure onwards would be ignored seperated with |". If you want 1.00000 as output, see Wiktor's comment. If your output should be anything else, (e.g. 1.00000|00) please give an example. – buddemat Oct 21 '20 at 07:54
  • 1
    Do you just want to remove all after `.` and five digits? `(\.\d{5}).*` -> `\1`? – Wiktor Stribiżew Oct 21 '20 at 07:56
  • apologies, its for a rule in a compare tool called beyond compare. I want it to ignore everything from the 5th decimal place between 2 files eg - file 1 - 266480237848.499974824 file 2 -266480237848.49997 – fatbij Oct 21 '20 at 09:59
  • Does my answer fit your question? Even with your clarification I am still unsure what you meant by "separated with |" – buddemat Oct 21 '20 at 21:53
  • Glad to be of help! Just one remark: Instead of thanking in the comments, you can better use other ways to show that the answer worked for you. See https://stackoverflow.com/help/someone-answers – buddemat Oct 23 '20 at 09:49

1 Answers1

1

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).

buddemat
  • 4,552
  • 14
  • 29
  • 49