No announcement yet.

Use Replacement to remove a character

  • Time
  • Show
Clear All
new posts

  • Use Replacement to remove a character

    is it possible to use a Replacement to remove a character? The idea seems sound, but the OK button is not enabled unless there is text in the Replace With box.


  • #2

    Replacements are designed to capture a changed phrase on both sides, so the phrase itself needs to exist on both sides. Can you define the replacement around the whole word? Such as:
    Word = WordA

    If you have a specific set of examples, I could try to help come up with a replacement rule.

    You could also define a character or RegEx to be generally Unimportant. We have a walkthrough and video on that, here:
    Aaron P Scooter Software


    • #3
      Thanks for the quick reply!

      I am comparing XML files where certain attribue values have had their underscores removed. There is no consistent context other than the underscore. For example:

      I had tried creating a Grammer rule for just _ and marking it unimportant. But it didn't seem to work, even when I made it the top grammer rule. I do have it working with another example though, so I think I was missing some other change in the lines I was comparing.

      That said, I have many other cases where I just want to say "ignore XYZ". Is there a technical reason why the Replacement can't have a blank "Replace With"? Adding all these one offs to the type/grammer seems be clutter when its really file specific.



      • #4
        Another way of describing what I would like is a "ignore all". Like the Ignored menu option, but it would apply for any text on that side that match the selected text. Like you can do with many spelling checkers (e.g. Microsoft Word).


        • #5
          In the spirit of your example, in a import/export one of my XML files gets a an attribute like 'visibility="true"' on all its elements (thousands). I would love to quickly ignore that chunk of text when comparing the files.

          In my personal case, after I have decided there are no other bad changes I will copy those changes over to the compare file so I really need to ignore them this one time.


          • #6

            For ignoring a chunk like that, you would want to follow the Define Unimportant Text kb article:

            Text Replacements must define the different text in the target explicitly. For an underscore removal, it would be something like:
            Find: ([^_]*)_([^_]*)
            Replace with: $1 $2

            With a definition for each potential whitespace character, since the difference (' ') must be in the Replace With section.

            It would probably be easier to create a grammar where just the '_' character was unimportant, though that individual character would be unimportant whenever it was different.
            Aaron P Scooter Software