Community
    • Login

    Deleting full words after certain length (after 36 char)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 458 Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          Net Buyer @Terry R
          last edited by

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

          1 Reply Last reply Reply Quote 1

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors