How to Remove unwanted space in Row After 4 Number?



  • How to Remove unwanted space in Row After 4 Number? Like this,
    0300 8229386
    0300 8253137
    0334 0210214
    0300 2692165

    03008229386
    03008253137
    03340210214
    03002692165

    Please help us?



  • @Jinko-Solar

    Not sure enough info has been provided to solve the complete problem, but try this against the sample data…maybe it will give you enough hints for the “bigger” problem:

    FInd ((^\d+.+\R){4})\R
    Repl \1
    Mode Regular expression



  • Sir, Sorry. It didn’t work.



  • @Jinko-Solar

    try this on your given example:

    find what: ^(\d+)(\s+)(.+)
    replace with: $1$3
    search mode: regular expression

    and hit replace all



  • @Jinko-Solar said:

    Sir, Sorry. It didn’t work.

    Oh yes it does. I could record a screencast of it working but it isn’t worth my time. :)



  • Hello, @jinko-solar, @alan-kilborn,@meta-chuh, and All,

    Here is a third solution :

    SEARCH ^(\d+)\h*

    REPLACE $1


    Regarding your regex S/R, Alan :

    SEARCH ((^\d+.+\R){4})\R

    REPLACE \1

    I don’t mean to be rude, but this regex S/R really does not work ! You’ve certainly found out a new version, afterwards ;-))

    Best Regards,

    guy038



  • @guy038

    I don’t mean to be rude

    No worries. Hmmm, it worked in RegexBuddy with all the same settings as Notepad++. I don’t think I’ve encountered a regex that works differently, so I didn’t check it in both, originally. But you are right, it won’t work in Notepad++. Moving the ^ to the very start outside the opening ( will work, however. I wonder what the difference is…



  • @guy038 said:

    [Alan’s] regex S/R really does not work

    I think I see what happened: based on the behavior of @Alan-Kilborn’s regex: I think he interpreted the request as “remove the blank line (ie, vertical space) after four rows that start with numbers”, which would be a reasonable interpretation of the OP’s phrasing. @Meta-Chuh and @guy038 both came up with regex that removed a horizontal space after four digits in a given row.

    Unfortunately, since @Jinko-Solar hasn’t chimed back in, we don’t yet know whether Meta or Guy got it right, either.

    edit: simulpost: I may have interpreted Alan’s intention wrong…



  • Hi, @jinko-solar, @alan-kilborn,@meta-chuh, @peterjones and All,

    Aaaaaaaaah I see ! Just the way to interpret the OP’s request !

    So, Alan, rest assured, your regex S/R is working as expected !

    Assumming the text :

    0300 8229386
    0300 8253137
    0334 0210214
    0300 2692165
    
    03008229386
    03008253137
    03340210214
    03002692165
    

    The regex S/R, below :

    SEARCH ((^\d+.+\R){4})\R      OR       ^((\d+.+\R){4})\R

    REPLACE \1

    will leave you with the text :

    0300 8229386
    0300 8253137
    0334 0210214
    0300 2692165
    03008229386
    03008253137
    03340210214
    03002692165
    

    Cheers,

    guy038


Log in to reply