• Login
Community
  • Login

Regular expression

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
2 Posts 2 Posters 794 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    adelinefiu
    last edited by adelinefiu Nov 16, 2018, 2:16 AM Nov 16, 2018, 2:15 AM

    Hello friends, I was practicing with Regular expression and I want to delete some columns and I am using the following code

    search for: ^([^ ]+?):([^ ]+?):([^ ]+?):([^ ]+?):([^ ]+?).*
    And replace with: $1:$5

    Kenty:level57:Elite:Knight:edrty
    Mawk:level69:Elder:Druid:12wer
    Pog:level122:Elite:Knight:3edrt
    Tygger:level34:Elder:Druid:eeee

    and the result I get is

    Kenty:e
    Mawk:1
    Pog:3
    Tygger:e

    everything works fine up to replace with $1:$4, but with the 5 column does not work something I’m doing wrong, I hope you help me solve it

    1 Reply Last reply Reply Quote 1
    • T
      Terry R
      last edited by Nov 16, 2018, 5:33 AM

      @adelinefiu
      You were very close. Just change the * for a +. The + is greedy and it will try to grab as many characters as possible up to the end of the line.

      Suggest read the FAQ, it has some good links. Also rexegg.com has a table outlining the meaning on the * and +.

      Terry

      1 Reply Last reply Reply Quote 1
      2 out of 2
      • First post
        2/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors