No announcement yet.

Replacement item using Regular expression on both side

  • Filter
  • Time
  • Show
Clear All
new posts

  • Replacement item using Regular expression on both side


    I have a text file compare with left side text of:
                <div id="n01">
                    <input name="p_topic" value="FTBL" onClick="checkboxChange(this)" id="n01_topicId" type="checkbox" checked="checked">
                    <label for="n01_topicId">Football</label>
                <div id="n02">
                    <input name="p_topic" value="SWMG" onClick="checkboxChange(this)" id="n02_topicId" type="checkbox" checked="checked">
                    <label for="n02_topicId">Swimming</label>
    and right side text of:
                <div id="n06">
                    <input name="p_topic" value="FTBL" onClick="checkboxChange(this)" id="n06_topicId" type="checkbox" checked="checked">
                    <label for="n06_topicId">Football</label>
                <div id="n03">
                    <input name="p_topic" value="SWMG" onClick="checkboxChange(this)" id="n03_topicId" type="checkbox" checked="checked">
                    <label for="n03_topicId">Swimming</label>
    (my full file has many more groups of this code)

    I'm trying to confirm the text is the same except wherever n<number><number> if found.

    I've tried a Replacement Item with Text to find being [0-9]* and Replace with also being [0-9]* (and Regular expression checkbox set, and Left radio set)(see attached screenshot). This doesn't seem to work (i.e. n01 and n02 on left and n06 and n03 on right aren't marked as unimportant differences).

    I also tried adding two Replacement Items with Text to find as [0-9]* and Replace with as xxxx (with Regular expression checked). I set this up as both a left and a right replacement, hoping Beyond Compare would apply the replacement from the first rule, then apply the second rule and show xxxx values in the comparison that are equal. This didn't work either.

    Is there another way to accomplish this task (inside beyond compare)? If not could either of these features (allow regular expression on both find and replace side or/and add an option for the replacement rule to forcefully apply the change as soon as the rule is met, in order of being applied) be a future option in Beyond compare?

    Last edited by GlenC; 18-Nov-2012, 07:24 PM.

  • #2

    Supporting the RegEx on both sides is on our wishlist but is not supported at this time. If you click the little dropdown arrow to the right of the textbox, you can see the supported RegEx commands for that textbox. The Replace With box does not support \d or other masking, and would require specifying the number.

    If you need to generally mark any "n\d\d" as unimportant, please try using our Unimportant grammar definitions.
    Beyond Compare is a multi-platform utility that combines directory compare and file compare functions in one package. Use it to manage source code, keep directories in sync, compare program output, etc.

    Please let us know if you have any questions.
    Aaron P Scooter Software


    • #3
      Thanks Aaron,

      Though a couple more steps than allowing regular expressions on both sides for just this one session the unimportant grammar achieves what is required.

      Thanks again.