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 6340171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:47:07+00:00 2026-05-24T19:47:07+00:00

In the program I’m working on, I need to strip the tags around certain

  • 0

In the program I’m working on, I need to strip the tags around certain parts of a string, and then insert a comma after each character WITHIN the tag (not not after any other characters in the string). In case this doesn’t make sense, here’s an example of what needs to happen –

This is a string with a < a > tag < /a > (please ignore the spaces within the tag)

(needs to become)

This is a string with a t,a,g,.

Can anyone help me with this? I’ve managed to strip the tags using RegEx, but I can’t figure out how to insert the commas only after the characters contained within the tag. If someone could help that would be great.

@Dour High Arch I’ll elaborate a little bit. The code is for a text-to-speech app that won’t recognize SSML tags. When the user enters a message for the text to speech app, they have the option of enclosing a word in a < a > tag to make the speaker say the world as an acronym. Because the acronym SSML tag won’t work, I want to remove the < a > tag whenever present, and place commas after each character contained in the tag to fake it out (ex: < a > test< /a > becomes t,e,s,t,). All the non-tagged words in the string do not need commas after them, just those enclosed in tags (see my first example if need be).

  • 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-24T19:47:07+00:00Added an answer on May 24, 2026 at 7:47 pm

    Parsing XML is very problematic because you may have to deal with things like CDATA sections, nested elements, entities, surrogate characters, and on and on. I would use a state-based parser like ANTLR.

    However, if you are just starting out with C# it is instructive to solve this using the built-in .Net string and array classes. No ANTLR, LINQ, or regular expressions needed:

    using System;
    
    class ReplaceAContentsWithCommaSeparatedChars
    {
        static readonly string acroStartTag = "<a>";
        static readonly string acroEndTag = "</a>";
    
        static void Main(string[] args)
        {
            string s = "Alpha <a>Beta</a> Gamma <a>Delta</a>";
            while (true)
            {
                int start = s.IndexOf(acroStartTag);
                if (start < 0)
                    break;
    
                int end = s.IndexOf(acroEndTag, start + acroStartTag.Length);
                if (end < 0)
                    end = s.Length;
    
                string contents = s.Substring(start + acroStartTag.Length, end - start - acroStartTag.Length);
                string[] chars = Array.ConvertAll<char, string>(contents.ToCharArray(), c => c.ToString());
                s = s.Substring(0, start)
                    + string.Join(",", chars)
                    + s.Substring(end + acroEndTag.Length);
            }
    
            Console.WriteLine(s);
        }
    }
    

    Please be aware this does not deal with any of the issues I mentioned. But then, none of the other suggestions do either.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The program takes a string using getline, and then passes that string to a
A program receives a list of Messages (base type). Each message in the list
Strange program hang, what does this mean in debug? After attaching windbg I found
program s; type info = record name, surname: string; min, sec: integer; end; arrays
Program: program s; type info = record name, surname: string; min, sek: integer; end;
{ class Program { static void Main(string[] args) { int id = 0, stock
class Program { static void Main(string[] args) { Console.WriteLine(Fib 1: ); Console.ReadLine(); } long
This program has the user input name / age pairs and then outputs them,
A program I am working on right now has to generate a file. Is
my program throws a std::bad_alloc. After debugging it, I found out it is thrown

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.