Can I consider “whole word” as the word with space separated only in notepad++?



  • Currently, if I have the following text

    5 0.5 4

    Then I do a “whole word only” replacement for 5 to 9, I will get

    9 0.9 4

    instead of

    9 0.5 4

    So how can I get 9 0.5 4? Is this doable within Notepad++?



  • This looks like a normal search and replace mode action. I’ve done this, but it’s been a while; You might have to use a special char for <sp>; but, probably not, as long as the search string and replacement string contains the space and the whole string as you wrote, it should work… Since you didn’t try; I’d say just try it, and make sure you have a backup of the file in case it goes wrong. I think there’s a special extended case for a <sp> but not sure what it is. If normal doesn’t work, that’ll work; but, you’ll have to use the Search mode: extended to do it at worst case. I"m working on learning RegEx (Regular Expression) search mode; it’s tough but doable. At least give ‘Normal’ search a try…





  • Yeah, using regex, I’m still picking up on that… still I don’t know why a simple search and replace wouldn’t work on that. Guess I’d have to give it a try to find out. ;-) So, perhaps I misunderstood the question. Nope, it works.

    Search 5 0.5 4 replace: 9 0.5 4 using normal



  • Hi @lanselibai,

    Sure that regexes can sort out all the cases where a 5 digit must be replaced by a 9 digit !!

    So, given the 10 numbers, below, containing one or several 5 digits :

    52.8
    3.457
    505
    10.5
    5
    0.345
    23558
    56789.5512557
    5555.5555
    0.000000005
    

    Which are the final expected form of each number ? Of course, I suppose that, in real files, these 10 numbers may lie in a single or on several lines

    From the results, It should be easy enough to build up the appropriate regex !

    Best Regards

    guy038


Log in to reply