C#: Using regular expression (Regex) to duplicate a specific character in a string

Posted by user3703944 on Stack Overflow See other posts from Stack Overflow or by user3703944
Published on 2014-06-05T15:05:20Z Indexed on 2014/06/05 15:25 UTC
Read the original article Hit count: 110

Filed under:
|
|

Anyone know how to use regex to duplicate a specific character in a string?

I have a path that is entered like this:

C:/Example/example

I would like to use regex (or any other method) to display it like this:

C://Example//example

Is it possible?

This is where I'm getting the file path

private void btnSearchImage_Click_1(object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();

        ofd.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp"; 

        if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            string filenName = ofd.FileName;
            pictureBox1.Image = new Bitmap(filenName);
            string path = filenName;
            txtimgPath.Text = path;

        }


    }

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex