Solved

insert a decimal in a number string

  • 22 September 2022
  • 6 replies
  • 15 views

Badge

Hi, I'm trying to insert a decimal into a string of numbers, so 123456 becomes 1234.56

 

Thanks!

icon

Best answer by carmijo 23 September 2022, 03:54

View original

6 replies

Badge +10

Hey there @dos_gis​, You can do this a few different ways. You could use regex inside the stringreplacer transformer like mentioned here -

http://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/stringreplacer.htm

or the stringinserter custom transformer

https://hub.safe.com/publishers/safe-lab/transformers/stringinserter

 

Here's a super helpful resource I use when working with regex - https://regex101.com/

---

If i've provided something helpful, please upvote the comment. If i've provided a solution, please mark it as 'Best Answer'. This marks the post as answered and helps the community find the solution. If I didn't provide a solution, please let me know if I can help further. Thanks! 🙂

Badge

Thanks. I've been trying the stringreplacer with regex:

[0-9]{2}+$

Replacement Text: .\\2

 

It's not adding the decimal just replacing the text

Badge +10

Thanks. I've been trying the stringreplacer with regex:

[0-9]{2}+$

Replacement Text: .\\2

 

It's not adding the decimal just replacing the text

Try this out - image 

--

If i've provided something helpful, please upvote the comment. If i've provided a solution, please mark it as 'Best Answer'. This marks the post as answered and helps the community find the solution. If I didn't provide a solution, please let me know if I can help further. Thanks! 🙂

Badge

Almost but my number string isn't always the same length. I'm looking to add a decimal in front of the last two numbers regardless of the string length.

Badge +10

Almost but my number string isn't always the same length. I'm looking to add a decimal in front of the last two numbers regardless of the string length.

This should work for you. image.png--

If i've provided something helpful, please upvote the comment. If i've provided a solution, please mark it as 'Best Answer'. This marks the post as answered and helps the community find the solution. If I didn't provide a solution, please let me know if I can help further. Thanks! 🙂

Badge

Thank you. This did the trick.

(\\d.{1})$

Replacement text: .\\1

Reply