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

  • SEARCH
  • Home
  • 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 6549693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:07:27+00:00 2026-05-25T12:07:27+00:00

I am writing a system whereby everything visible to the user is translatable. This

  • 0

I am writing a system whereby everything visible to the user is translatable. This means that every paragraph, title, link text, tooltip etc is contained in a database table and I am using tags to get the data. For example [Tag 1] may be Login or it could be changed to something else – it’s definable by the company itself.

I have this working perfectly. I am overriding the Render method in the Page class to replace all these tags. I have a regex to match all tags in the format [tag x] where x is 1 or more numbers, i.e. the ID of the translation in the database; the regex I am using is @"\[(Text|Tag) ([0-9]*)].

The problem I am having is that, for example, if you have a tag within a tag – for example [tag 69] is defined as [tag 70][tag 71][tag 72] – when the text is inside a textarea it is still replaced, so tag 69 will appear as the other 3 put together. I’d like to prevent replacements on tags contained within textareas. My first thought was that this would be easy – but then I realised that if you had <textarea>[tag 1]</textarea>[tag 2]<textarea>[tag 3]</textarea>, tag 2 would not be replaced.

I have to admit I am no pro at regular expressions – I would like to be but I don’t have the time on my hands at the moment. Can anyone suggest a way that I could achieve what I’d like to achieve? Thanks in advance.

Regards,
Richard

  • 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-05-25T12:07:28+00:00Added an answer on May 25, 2026 at 12:07 pm

    So the question is how to match a [Tag n] that isn’t enclosed inside a textarea? You can use a negative look-behind for that.

    (?<!\<textarea\>)\[(tag|text) [0-9]+\]
    

    The code:

    var input = "<textarea>[tag 1]</textarea>[tag 2]<textarea>[tag 3]</textarea>";
    Regex regex = new Regex(@"(?<!\<textarea\>)\[(tag|text) [0-9]+\]");
    
    var matches = regex.Matches(input);
    foreach (var match in matches)
    {
       Console.WriteLine(match);
    }
    

    Outputs:

    [tag 2]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am writing a system for a user that on filling in a
I writing a Linux system call map for the radare2 debugger. This means providing
I'm writing a plugin system: every plugin is in his own assembly that must
I've been writing a system that at runtime generates some templates, and then generates
I'm writing a workflow system that is driven entirely at each step by explicit
I'm writing a system that underlies programmer applications and that needs to detect their
I'm having trouble with writing a System.Xml.XmlElement to disk using C# .NET. This is
I'm writing a system at the moment that needs to copy data from a
I'm writing a system utilizing jQuery Validation that pulls in custom rules, messages via
Hopefully, this fictitious example will illustrate my problem: Suppose you are writing a system

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.