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

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,

1 Like

thank you

1 Like

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

Hi,

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

Regards,

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