Skip to content

Separator every N characters

Assume you have the following string: 123456789 and you want it to be 123.456.789, you can use this code line to add the decimal point as seperator each 3 characters:

Regex.Replace(myString, ".{3}", "$0.");

You can replace the decimal point in $0. with the char you want to use as a seperator.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.