Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Regular expression

    Help wanted · · · – – – · · ·
    2
    2
    553
    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.
    • adelinefiu
      adelinefiu last edited by adelinefiu

      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
      • Terry R
        Terry R last edited by

        @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
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors