Community
    • Login

    adding incremental number between ' '

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 200 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.
    • SpeedRiderS
      SpeedRider
      last edited by

      '13':
          type: SHOP
          id: SPRUCE_WOOD
          buy-price: 200.0
        '14':
          type: SHOP
          id: BIRCH_LOG
          buy-price: 200.0
        '15':
          type: SHOP
          id: BIRCH_WOOD
          buy-price: 200.0
        '16':
          type: SHOP
          id: JUNGLE_LOG
          buy-price: 200.0
        '17':
          type: SHOP
          id: JUNGLE_WOOD
          buy-price: 200.0
        '18':
          type: SHOP
          id: ACACIA_LOG
          buy-price: 200.0
        '19':
          type: SHOP
          id: ACACIA_WOOD
          buy-price: 200.0
        '20':
          type: SHOP
          id: DARK_OAK_LOG
          buy-price: 200.0
        '21':
          type: SHOP
          id: DARK_OAK_WOOD
          buy-price: 200.0
        '22':
          type: SHOP
          id: SPONGE
          buy-price: 260.0
        '23':
          type: SHOP
          id: BRICKS
          buy-price: 270.0
        '24':
          type: SHOP
          id: WHITE_WOOL
          buy-price: 320.0
      

      I would like to be able to replace all the numbers inside the ‘0-1000’

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by

        Hello, @speedrider and All,

        Here is my solution :

        From your text :

          '13':
            type: SHOP
            id: SPRUCE_WOOD
            buy-price: 200.0
          '14':
            type: SHOP
            id: BIRCH_LOG
            buy-price: 200.0
          '15':
            type: SHOP
            id: BIRCH_WOOD
            buy-price: 200.0
          '16':
            type: SHOP
            id: JUNGLE_LOG
            buy-price: 200.0
          '17':
            type: SHOP
            id: JUNGLE_WOOD
            buy-price: 200.0
          '18':
            type: SHOP
            id: ACACIA_LOG
            buy-price: 200.0
          '19':
            type: SHOP
            id: ACACIA_WOOD
            buy-price: 200.0
          '20':
            type: SHOP
            id: DARK_OAK_LOG
            buy-price: 200.0
          '21':
            type: SHOP
            id: DARK_OAK_WOOD
            buy-price: 200.0
          '22':
            type: SHOP
            id: SPONGE
            buy-price: 260.0
          '23':
            type: SHOP
            id: BRICKS
            buy-price: 270.0
          '24':
            type: SHOP
            id: WHITE_WOOL
            buy-price: 320.0
        

        Do this regex S/R :

        • SEARCH \R(?!\h*')|('\d+')

        • REPLACE ?1'':|

        • Select the Regular expression search mode

        You should get this text :

          '':|    type: SHOP|    id: SPRUCE_WOOD|    buy-price: 200.0
          '':|    type: SHOP|    id: BIRCH_LOG|    buy-price: 200.0
          '':|    type: SHOP|    id: BIRCH_WOOD|    buy-price: 200.0
          '':|    type: SHOP|    id: JUNGLE_LOG|    buy-price: 200.0
          '':|    type: SHOP|    id: JUNGLE_WOOD|    buy-price: 200.0
          '':|    type: SHOP|    id: ACACIA_LOG|    buy-price: 200.0
          '':|    type: SHOP|    id: ACACIA_WOOD|    buy-price: 200.0
          '':|    type: SHOP|    id: DARK_OAK_LOG|    buy-price: 200.0
          '':|    type: SHOP|    id: DARK_OAK_WOOD|    buy-price: 200.0
          '':|    type: SHOP|    id: SPONGE|    buy-price: 260.0
          '':|    type: SHOP|    id: BRICKS|    buy-price: 270.0
          '':|    type: SHOP|    id: WHITE_WOOL|    buy-price: 320.0|
        
        • Now place the caret between the first '' zone

        • Open the Column editor ( Alt + C ) and renumber as you like

        • Don’t forget to tick the Leading zeros option

        For instance, we could end with this text :

          '01':|    type: SHOP|    id: SPRUCE_WOOD|    buy-price: 200.0
          '02':|    type: SHOP|    id: BIRCH_LOG|    buy-price: 200.0
          '03':|    type: SHOP|    id: BIRCH_WOOD|    buy-price: 200.0
          '04':|    type: SHOP|    id: JUNGLE_LOG|    buy-price: 200.0
          '05':|    type: SHOP|    id: JUNGLE_WOOD|    buy-price: 200.0
          '06':|    type: SHOP|    id: ACACIA_LOG|    buy-price: 200.0
          '07':|    type: SHOP|    id: ACACIA_WOOD|    buy-price: 200.0
          '08':|    type: SHOP|    id: DARK_OAK_LOG|    buy-price: 200.0
          '09':|    type: SHOP|    id: DARK_OAK_WOOD|    buy-price: 200.0
          '10':|    type: SHOP|    id: SPONGE|    buy-price: 260.0
          '11':|    type: SHOP|    id: BRICKS|    buy-price: 270.0
          '12':|    type: SHOP|    id: WHITE_WOOL|    buy-price: 320.0|
        

        Now, use this simple regex S/R to get your initial list :

        SEARCH \|

        REPLACE \r\n for Windows files    OR    \n for Unix files

          '01':
            type: SHOP
            id: SPRUCE_WOOD
            buy-price: 200.0
          '02':
            type: SHOP
            id: BIRCH_LOG
            buy-price: 200.0
          '03':
            type: SHOP
            id: BIRCH_WOOD
            buy-price: 200.0
          '04':
            type: SHOP
            id: JUNGLE_LOG
            buy-price: 200.0
          '05':
            type: SHOP
            id: JUNGLE_WOOD
            buy-price: 200.0
          '06':
            type: SHOP
            id: ACACIA_LOG
            buy-price: 200.0
          '07':
            type: SHOP
            id: ACACIA_WOOD
            buy-price: 200.0
          '08':
            type: SHOP
            id: DARK_OAK_LOG
            buy-price: 200.0
          '09':
            type: SHOP
            id: DARK_OAK_WOOD
            buy-price: 200.0
          '10':
            type: SHOP
            id: SPONGE
            buy-price: 260.0
          '11':
            type: SHOP
            id: BRICKS
            buy-price: 270.0
          '12':
            type: SHOP
            id: WHITE_WOOL
            buy-price: 320.0
        

        Voila !

        Best Regards,

        guy038

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