How to 'System.Text.RegularExpressions.Regex.Replace'

I want to know how to change the following using regular expression.

input data : 123456

after replace : 12-34-56

1 Like

Hi,

I suppose your requirement is not very clear, however the following will work.

System.Text.RegularExpressions.Regex.Replace(yourString,"(?<=\d{2})(\d{2})(?=\d{2})","-$1-")

Regards,

3 Likes

thank you

2 Likes

Im sorry.
What does ‘-$1-’ mean?

Hi,

$1 means Substitutions. See the following document in details.

Regards,

1 Like

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