Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:30:46+00:00 2026-06-12T06:30:46+00:00

I am trying to use Regex.Replace to create a hyperlink. I want to make

  • 0

I am trying to use Regex.Replace to create a hyperlink. I want to make it so the user can hit a button that I have created and create a product link. This way if the url changes for some reason it I wont have to change the logic in the data entry side. The user will be submitting a body of text and I will have something formatted like this:

"[!product:123456:Click Me!]" 

Where p stands for product. Click Me is the text displayed on the link. 123456 is the identifier. The link should look like this:

<a href="www.mywebsite.com/product/123456">Click Me</a>

So far I have this:

var output = Regex.Replace(model.Body, @"\[!([^!]*)\!]", "<a href='http://www.mywebsite.com/$1'> link </a>");

Which returns:

 http://www.mywebsite.com/p:165411:Click Me

Is there any way I can do a Regex that will allow me to parse between [! and !] to seperate out the data that is seperated by “:”?

Here is what I am thinking:

var output = Regex.Replace(model.Body, SOME REGEX HERE, "<a href='http://www.mywebsite.com/$1/$2'> $3 </a>");

Hopefully this is enough information on what I am trying to do. Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:30:47+00:00Added an answer on June 12, 2026 at 6:30 am

    How about this regex?

    \[!(.*):(.*):(.*)!\]
    

    In c# that is

    using System;
    using System.Text.RegularExpressions;
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                var text = "[!product:123456:Click Me!]";
                var regex = new Regex("\\[!(.*):(.*):(.*)!\\]", RegexOptions.IgnoreCase);
    
                var result = regex.Replace(text, "<a href='http://www.mywebsite.com/$1/$2'> $3 </a>");
                Console.WriteLine(result);
                Console.ReadKey();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use regex generators to create an expression, but I can't
trying to use regex to replace any white space with &nbsp;, inside of example
I am trying to use this regex (JS): /\/\*(.*)\*\//g To replace /* sdandsads */
I'm trying to use regex to match a string that starts with a <p>
I have a prob. I'm trying to create a custom slugify functiom. I use
I am trying to use regex.replace to strip out unwanted characters, but I need
I've been scratching my head trying to figure out how to use Regex.Replace to
I'm trying to use regex to replace source attribute (could be image or any
I have been trying to use a C# Regex unsuccessfully to remove certain strings
I have attempted to create a function that will replace multiple regular expression values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.