How to convert to a specific format?

I’m trying to convert a number or * text to the format “XXXX-XXXX-XXXX-XXXX”.
For example, I would like to convert
image

How should I use regular expressions?

Hi @bbbb

System.Text.RegularExpressions.Regex.Replace(inputString, ".{4}(?!$)", "$0-")

Regards
Chandrika

Let me ask you one more thing. How should I write a regular expression to express 3-digit numbers - 2-digit numbers - 5-digit numbers?
0000000000 → 000-00-00000

System.Text.RegularExpressions.Regex.Replace(inputString, "(\d{3})(\d{2})(\d{5})", "$1-$2-$3")

Regards,
Chandrika.

Perfect! thank you:)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.