PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 17, 2022

[FIXED] How to ignore specific char while reading SpeechSynthesizer C#?

 August 17, 2022     c#, output, speech-synthesis, voice     No comments   

Issue

I have some string which goes as follows

TEST___5____345

How can I make SpeechSynthesizer to ignore the underscore chars while reading, as its annoying ?


Solution

The code below splits your string using the underscore as the separator. Adding the StringSplitOptions.RemoveEmptyEntries removes all empty string that would occur when multiple sequential underscores are in your inputstring.

using System;

namespace IgnoreUnderscore
{
    class Program
    {
        static void Main(string[] args)
        {
            var str ="TEST___5____345";

            var arr = str.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < arr.Length; i++)
            {
                Console.WriteLine(arr[i]);
            }

            Console.ReadKey();
        }
    }
}

Output is


TEST
5
345



Answered By - Paul Sinnema
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing