Skip to main content
Solved

insert a decimal in a number string

  • September 22, 2022
  • 6 replies
  • 204 views

dos_gis
Contributor
Forum|alt.badge.img+3

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

 

Thanks!

Best answer by carmijo

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! 🙂

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

carmijo
Supporter
Forum|alt.badge.img+11
  • Supporter
  • 135 replies
  • September 22, 2022

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! 🙂


dos_gis
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • 17 replies
  • September 22, 2022

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


carmijo
Supporter
Forum|alt.badge.img+11
  • Supporter
  • 135 replies
  • September 22, 2022

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! 🙂


dos_gis
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • 17 replies
  • September 22, 2022

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.


carmijo
Supporter
Forum|alt.badge.img+11
  • Supporter
  • 135 replies
  • Best Answer
  • September 23, 2022

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! 🙂


dos_gis
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • 17 replies
  • September 23, 2022

Thank you. This did the trick.

(\\d.{1})$

Replacement text: .\\1