Community
    • Login

    Deleting full words after certain length (after 36 char)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 251 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.
    • Net BuyerN
      Net Buyer
      last edited by

      Hi Guys,

      Please help me in removing all words after 36 characters as below example.

      Source
      <NAME>GOOGLE-YOUTUBEPREMIUM (Length 27 char)
      <NAME>APPLE.COM-BILL 866-712-7753 ON (Length 36 char)
      <NAME>GOOGLE-YOUTUBEPREMIUM INTERNET NS (Length 39 char)
      <NAME>AMZN Mktp CA-2P5L787T1 WWW.AMAZON.CAON (Length 44 char)

      Result
      <NAME>GOOGLE-YOUTUBEPREMIUM
      <NAME>APPLE.COM-BILL 866-712-7753 ON
      <NAME>GOOGLE-YOUTUBEPREMIUM INTERNET
      <NAME>AMZN Mktp CA-2P5L787T1

      Thanks for you help.

      1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R
        last edited by

        @Net-Buyer said in Deleting full words after certain length (after 36 char):

        Please help me in removing all words after 36 characters as below example.

        You could try the following using the Replace function.
        Find What:(?-s)^(?=.{37,})(.{1,36})\s.*
        Replace With:$1
        Search mode must be “Regular expression”.

        As some background we have
        (?-s) - DOT character does NOT include the newline characters
        ^(?=.{37,}) - check if the line is 37 characters or more, otherwise we don’t process it
        (.{1,36})\s.* - look for up to 36 characters followed by a space (blank), this is captured in group 1, select the remainder of the line, but don’t capture it.
        $1 - means return the captured portion only, thus the first (up to) 36 characters are
        written back.

        Terry

        Net BuyerN 1 Reply Last reply Reply Quote 2
        • Net BuyerN
          Net Buyer @Terry R
          last edited by

          @Terry-R : Thanks for your help. Worked like charm.

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