How to Add a Period to Data with "Data Format"

I need to add a period to the alphanumeric data but cannot find how to do it under “data format.”
This is an example of what I need to do:

F3112 -> F31.12
F208 -> F20.8

The period must occur after the third character.

Please advice.

You will possibly hate the way i would do this but it might give you some ideas. This is using client side data formatters.
Lets say in your document you have a repeat on a row that is filled from a database query, and one of the fields in your database table is “email” as an example, well here is a code example.

<div class="row" is="dmx-repeat" id="repeat_email" dmx-bind:repeat="">
  <div class="col">
    <p>{{g_email.trunc(3, false, "." + (g_email.substr(3)))}}</p>

To do this, select you binding of {{email}}
Click the data formatters button, right click email and choose Manipulation > Truncate
Max Length 3 > Kind Literal > Type Number
Use Word Boundary > Uncheck to set to false
Append . > Kind Literal > Type Text (Right click the Append Step > Operation > +)

Value email > Kind Variable > Type Text (Right click the variable email > choose Manipulation > Sub)
Start 3 > Kind Literal > Type Number
Length > Kind Literal > Type Text (I had to enter a number here, then delete it in my code)

Hope this helps, good luck

@jcr just use the “Sub” formatter (substring) in the app connect data formatter:

It allows you to specify the start and length of the string, so in your case it would be:
The first part start from first position (0) and get the next 3 characters:
{{someBindingHere.substr(0, 3)}}
Then just enter the period:
And then the second part - start from the 3rd position and get the next characters (not sure how long your strings are so it’s safe to enter 10):
{{someBindingHere.substr(3, 10)}}

The generated code is:
{{someBindingHere.substr(0, 3)}}.{{someBindingHere.substr(3, 10)}}

I was able to added manually the data instructions per your example and it worked.

When I tried adding it to “data formats” the first step worked flawlessly, but when I added the period to the resulting text under “text” for the second part, I got an error message: “Error during parsing: Unexpected token, expecting [COLON]. expression: {{{{dxcode.substr(0, 3)}}.{{dxcode}}”

I am sure you meant a different way to add the period that’s why I get the error.

Your example shows 4 { { { { starting the expression and that is too many for what you are closing
use this {{dxcode.substr(0, 3)}}.{{dxcode}}
or this {{dxcode.trunc(3, false, “.” + (dxcode.substr(3)))}}

It also depends on how you are placing it as to how the code should look, if it is in a repeat it could be different, if it is in a tag like


then that is also different and what the code examples above are designed around. If you are binding the value then the expressions need to change, I mean like this dmx-

This is what I added and it did the trick: {{dxcode.substr(0, 3)}}.{{dxcode.substr(3, 7)}}

I appreciate the feedback.


Glad it is all working, congratulations.