0

Today I learned about regular expressions. Today I also learned that I'm terrible at regular expressions!

I've been toying around with them and have an understanding of some features but what I actually need is vastly ahead of my current knowledge.

Working with thousands of lines like this I need to convert the following:

        "MeshURL": "http://cloud-3.steamusercontent.com/ugc/1689401550837946539/FEC7DBCEEDA29A385ADE5D797055307ADB992B03/",
        "DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/1689401550837944885/196661E00A9EF450B9F008C9126DE66B25E4AAA0/",
        "ColliderURL": "http://cloud-3.steamusercontent.com/ugc/1689401550837946539/FEC7DBCEEDA29A385ADE5D797055307ADB992B03/",

Into the following:

        "MeshURL": "file:///C:\Users\X\Documents\My Games\Tabletop Simulator\Mods\Models\httpcloud3steamusercontentcomugc1689401550837946539FEC7DBCEEDA29A385ADE5D797055307ADB992B03",
        "DiffuseURL": "file:///C:\Users\X\Documents\My Games\Tabletop Simulator\Mods\Images\httpcloud3steamusercontentcomugc1689401550837944885196661E00A9EF450B9F008C9126DE66B25E4AAA0",
        "ColliderURL": "file:///C:\Users\X\Documents\My Games\Tabletop Simulator\Mods\Models\httpcloud3steamusercontentcomugc1689401550837946539FEC7DBCEEDA29A385ADE5D797055307ADB992B03",

For easier parsing, the distinctions are:

  • Removing all symbols from the original URL so it's plain text.
  • Replacing "http://" with file:///address (address location dependant on first word in line)

I'm not sure how complex this is, but I theorize it may require tackling in multiple steps. Plus I may need to relocate all files into a single folder for simplicity. Any advise is appreciated although a copy-paste solution would make my day!

Thank you for your time.

Edit: So I'm able to search for URL's with http[^"]+ and I'm able to search for symbols with [^a-zA-Z0-9] but I can't figure out how to combine the search criteria.

Edit2: **Found assistance elsewhere and scripted the process. Thankyou for the suggestions. **

6

1 Answer 1

-3

I'd think sed would do this in a jiffy. But you're unwilling to learn. I also think the biggest problem is the c:/ part of it, if you got rid of that then everything becomes zen.

2
  • 2
    This should be a comment.
    – Toto
    May 25 at 10:14
  • sed has nothing to do with Notepad++, and sed basically uses the same regex as Notepad++
    – phuclv
    May 25 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.