notepad++ - Regular Expression to replace part of URL in XML file

25
2013-11
  • Richie086

    I need a regular expression in Notepad++ to search/replace a string. My document (xml) has serveral thousand lines that look similar to this:

    <Url Source="Output/username/project/Content/Volume1VolumeName/TopicFileName.htm" />

    I need to replace everything starting from Volume1 to .htm" /> to replaced with X's or some other character to mask the actual file names in this file.

    So the resulting string would look like this after the search/replace was performed:

    <Url Source="Output/username/project/Content/Volume1XxxxxxXxxx/XxxxxXxxxXxxx.htm" />

    I am working with confidential information that I cannot release to people outside of my company, but i need to send an example log file to a 3rd party for troubleshooting purposes.

    FYI the X's do not need to follow the upper/lower case after the replacement, i was just using different case X's for the hell of it :)

  • Answers
  • David

    You can use word1.*.word2 to replace anything between two words, like so:enter image description here

    ![Notepad++ Regex][2]


  • Related Question

    regex - Notepad++ regular expression help
  • Questioner

    I'm a total newb with expressions and looking for a quick way to do this. Trying to delete everything in between the && to TAG

    URL GOTO=http://www.URLHERE.com/&&TXT:Just<SP>Because<SP>I'm<SP>Skinny<SP>Does<SP>NOT<SP>Mean<SP>I<SP>Have<SP>an<SP>Eating<SP>Disorder
    TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=VALUE:Submit
    

  • Related Answers
  • Max

    Replace this:

    &&.*?\bTAG\b
    

    with an empty string. That will do it. It also makes sure that "TAG" is a separate word. You should also turn on multiline mode if the line break in your example is not only for formatting, or use:

    &&[\s\S]*?\bTAG\b