2 Replies Latest reply on Oct 31, 2012 8:17 AM by Peter Spier

    need a grep code


      I need a help from for my book, i am not that much great in using grep codes or creating one.


      I need to find a (Number)(space) and replace it with the same number but removing only the space


      can you help me with this?




        • 1. Re: need a grep code
          Jump_Over Level 5



          Find Grep:


          Change Grep:



          If it could be one or more numbers make it : \d+

          one or more spaces : \x{20}+


          space means spacebar pushed here. If it could by ANY space (even tab, return and so on) make it:

          \s  instead of \x{20}



          • 2. Re: need a grep code
            Peter Spier Most Valuable Participant (Moderator)

            Unless it matters how many digits are in the number there is no reason to search for more than the last one, so \d is sufficient.


            I might search instead for (?<=\d)\x{20} which is a positive look-behind for any digit followed by an ordinary space, or (?<=\d)\s which will find any sort of white space following a digit in case there is some other type of space involved, then repalce with nothing.


            This sort of search is fraught with danger. The generic versions will find ANY combination of a digit followed by a space, like a date, and you may not want that, so you need to be careful in how you specify the search range or limit the search parameters to certain styles, etc., or be prepared to step though one by one.