skip to Main Content

I have one situation there I need to remove the array index from file

[0] => https://demo.com/alabama/18-wheeler-towing
[1] => https://demo.com/alabama
[2] => https://demo.com/alabama/winston-county/18-wheeler-towing
[3] => https://demo.com/alabama/winston-county
[4] => https://demo.com/service/18-wheeler-towing-addison-al
[5] => https://demo.com/alabama/winston-county/addison

I have a file there there thousands of link but I need something like

https://demo.com/alabama/18-wheeler-towing
https://demo.com/alabama
https://demo.com/alabama/winston-county/18-wheeler-towing
https://demo.com/alabama/winston-county
https://demo.com/service/18-wheeler-towing-addison-al
https://demo.com/alabama/winston-county/addison

How can I remove this array index using any file editor like vs code

2

Answers


  1. On Visual Studio Code you may use the multi cursor, add as many cursors you want in either direction and delete the indexes by pressing the backspace or delete key.

    VS Code supports multiple cursors for fast simultaneous edits. You can add secondary cursors (rendered thinner) with Alt+Click. Each cursor operates independently based on the context it sits in. A common way to add more cursors is with Ctrl+Alt+Down or Ctrl+Alt+Up that insert cursors below or above

    GIF outlining how one may use the multicursor on VScode

    Login or Signup to reply.
  2. If the index of array may have more than 1 digit, you can do with Notepad++:

    • Ctrl+H
    • Find what: ^.+?(?=https)
    • Replace with: LEAVE EMPTY
    • TICK Wrap around
    • SELECT Regular expression
    • UNTICK . matches newline
    • Replace all

    Explanation:

    ^           # beginning of line
    .+?         # 1 or more any character but newline, not greedy
    (?=https)   # positive lookahead, make sure we have "https" after
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search