18 Replies Latest reply on Jan 30, 2015 4:35 AM by jaduj1827153

    Advanced regex replacement

    Dapeamel

      Hello guys

      I am working on a replacement in document

      all is about I want to fix the Regex grep in one replace but I haven't figured it out yet,

      I know how to do the replace in two replaces

      I want to sucess in one replacement... if its possible

      the document is filled with this format in tables see below.

       

      398 480

      109 870

      72 836

      14 344

      1 586 365

       

      I want to have this format see below.

       

      398,480

      109,870

      72,836

      14,344

      1,586,365

       

       

      grep search for:(\d{1,3})( )(\d{3})( ?)(\d{3})?  

      replace:$1,$3 $5

       

      result:

      398,480

      109,870

      72,836

      14,344

       

      the grep doesn't work on 1,586,365

      but if I do in a second search and replace it grep also 1,586,365

       

      (\d{1})(,)(\d{3})( )(\d{3})

      $1$2$3,$5

       

       

      I read about look behind and look ahead conditionals.

      here is an example below how to specify which groups the regex grep will pick.

      (a)?b(?(1)(c|d)

       

      but its still hard to get the regex grep right in one replace

      do someone got experience of this kind of replacement

      please help me out

       

      Thank you in advance best members