Regex for devision class number

Hello!
Can you please tell me what regular expression can be used to divide a multi-digit number/decimals into class numbers with non-breaking spaces

Only thing that worked looks very strange and it's not multipurposal.

E.g. for 9-digit number I used Find&Replace function

123456789

Find what: ([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])

Replace with: $1$2$3$ 4$5$6$ 7$8$9

This one could be used, but it absolutely useless with decimals 

Parents
  • I think a few more examples would be good.  For example the numbers could be these based on your description:

    1,234,567.432234

    3,45

    3 456 567,2

    Or do you mean multidigit numbers that have just not been given the thousand/decimal separators?  In which case what do yo do with this?

    123456789

    It could be any of these I suppose:

    1,234,567.89

    12,345,678.9

    123,456,789

    12,345.6789

    1,234.56789

    123.456789

    I used commas and point to illustrate the point... I know you asked for spaces, but you also said decimals.  So where does the decimal go?

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

  • Thank you Phil for your answer.

    All your examples are relevant. (But if you can help me to divide integers without taking decimals it will be a great job too) 

    I had a table with a lot of so kind of numbers

    I wanted to divide into classes just integers, there were thousands, millions, billions, etc.

    For these tasks I used:

    Find what: ([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])

    Replace with: $1$2$3$ 4$5$6$ 7$8$9

    then 

    Find what: ([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])

    Replace with: $1$2 $3$4$5 $6$7$8

    etc. (every next step I I shortened the expression by one digit)

    But sometimes there were some decimals, and I had to do a lot of work just manually. So I'm trying to find more convenient way to work with this.

    Thank you

Reply
  • Thank you Phil for your answer.

    All your examples are relevant. (But if you can help me to divide integers without taking decimals it will be a great job too) 

    I had a table with a lot of so kind of numbers

    I wanted to divide into classes just integers, there were thousands, millions, billions, etc.

    For these tasks I used:

    Find what: ([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])

    Replace with: $1$2$3$ 4$5$6$ 7$8$9

    then 

    Find what: ([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])

    Replace with: $1$2 $3$4$5 $6$7$8

    etc. (every next step I I shortened the expression by one digit)

    But sometimes there were some decimals, and I had to do a lot of work just manually. So I'm trying to find more convenient way to work with this.

    Thank you

Children
No Data