PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label speech-synthesis. Show all posts
Showing posts with label speech-synthesis. Show all posts

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)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

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
All Comments
Atom
All Comments

Copyright © PHPFixing