Community
    • Login

    Slick way to remove line numbers from text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 18.8k 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.
    • Kent HartlandK Offline
      Kent Hartland
      last edited by

      Perhaps you already have a way to do this, but I thought I’d share.

      If you need to remove line numbers from program code or whatever, a slick and fast free utility is online at:

      http://remove-line-numbers.ruurtjan.com/

      Go there, paste your code and it strips all line numbers quickly and reliably.

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

        Hello @kent-hartland,

        Thanks for sharing this easy utility !

        However, you can achieve it, quickly enough, using regular expressions, in search/replacement, within N++ ;-))

        • Open your file, in N++

        • Eventually, do a normal selection of the lines to be processed

        • Open the Replace dialog ( Ctrl + H)

        • Type in the regex ^\h*\d+ , in the Find what: zone

        • Leave the Replace with: zone EMPTY

        • If you did a selection, tick the In selection option. Otherwise, tick the Wrap around option

        • Select the Regular expression search mode ( IMPORTANT )

        • Click on the Replace All button

        Et voilà !


        Note that this regex is, simply, an approximation of what that small utility does ! Indeed, this program :

        • Considers, only, the usual latin digits ( with Unicode value, from \x{0030} to \x{0039} ) as numbers to be deleted, instead of all Unicode numbers or similar, of any language !

        • Considers the first dot character ( . ), located right after a number, as a character to be deleted, too !

        • Considers all possible Unicode White space character ( except for the New Line character, \x{0085} ) , between the End of Line characters of the previous line and the numbers, of the current one, as characters which have to be deleted , as well. Refer, for that topic, to :

        http://www.unicode.org/Public/UCD/latest/ucd/PropList.txt


        So, assuming you would add a line-break, at the very beginning of your file, an exact search regex could be :

        (\r\n|\r|\n)\K[^\S\x85]*[0-9]+\.?

        Just for information, this regex :

        • First, the part (\r\n|\r|\n) tries to match some End of line character(s)

        • Then, the \K syntax reset the regex engine search process and position

        • Now, the part [^\S\x85]* finds the longest sequence, possibly empty, of White Space characters, different of \x{0085}

        • After, the part [0-9]+ simply looks for the longest non-empty range of classical digits

        • Finally, the syntax \.? searches a possible literal dot


        Remark :

        The part [^\S\x85] is difficult enough to understand : this negative class of characters [^...] represents a single character, which is DIFFERENT from, BOTH :

        • Any Unicode NON-Space character ( \S )

        • The New Line character ( \x{0085} )

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 0

        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