I am currently working on a project where I need to convert 4-digit numbers into a versioning system format. Specifically, I want to insert a dot (.) after each digit in the number. For instance:
Input String: 6536 Desired Output: 6.5.3.6
To achieve this, I tried using the “Value Mapping” feature with Regex, but unfortunately, I haven’t been successful. Here’s the regex pattern and display text that I’ve been using:
Regex Pattern: \d\d\d\d Display Text: $1.$2.$3.$4
However, this doesn’t seem to be working as expected, and I’m not sure what I might be doing wrong.
Could someone please help me figure out the correct way to achieve this? Your assistance would be greatly appreciated.
Hi, are you sure it’s a String you receive?
Just asking, because regex only works with String, not Number.
You can debug the data if you select “Query inspector” and verify the response you get. If it’s a String the value, it is shown between quotes like: “123456”
If not, you can always add a mapping to force the number to become a String, add below on the last line, replace columnName with the column holding your values that requires change →
|> map(fn: (r) => ({r with columnName: string(v: r.columnName)}))
Hi, just wanted to check, does my solution work for you, or are you still facing same issues Please contact me if you need any help, I will be happy to help you here