Guruji Point - Code You Want To Write

  • Home
  • Asp.Net
  • WCF
  • SQL
  • Type Script
  • AngularJS
  • Tech News
  • Blog
  • Earn Online

Friday, 27 October 2017

Replace all Special Character From String In C# Using Regex / RegularExpression

 guruji point, Gurujipoint, regex, regular expression, remove special character using regex c#     No comments   


Introduction
In this article we will learn how to use regular expression/regex in c#  and use regex to replace all special characters with space in string using c#. 

Previous Updates
In previous articles we have learnt Showing Chart With Database In Asp.Net Using C#. Get TextBox , Dropdown, CheckBox  control Values In Aspx.cs Page From User Control Using C#.

Description:
If you think you need to remove all the special character from string looks tough to do or need some special logic to implement. But here you dont need to worry about anything , Regex will do all the work for you. A simple line of code of regex solve your many problems.

 Maintain state of dynamic added userConrol in asp.net using c#.

using System.Text.RegularExpressions;   //paste this line in namespace


class Program
{
  static void Main(string[] args)
 {
    string myStr = "You-Are@visiting@-GurujiPoint@@.com";
    string output= Regex.Replace(myStr, "[^a-zA-Z0-9_]+", " ");
    Console.WriteLine(output);
    Console.ReadLine();
   }
}
Insert Only Numeric values in Asp Textbox using Regex.

Output:
You Are visiting GurujiPoint.com


  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to TwitterShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Facebook Updates

Guruji Point

Categories

comma seperated string in sql Comman table Expression in SQL Dynamic Grid Row IQueryable in c# Learn AngularJS row_number() and dense_rank() salary table structure. Scope_Identity() Use of indexes while loop in sql why do we need cursor why tuple used

About Us

This blog is about the Programming ,Tech News and some intresting facts related Contents. Here you can find fundamental and expert level topic of programming languages very practically related to C# , Asp.Net ,Sql-Server, JavaScript, Jquery, WebServices And also Web-Api, WCF ,WPF, Angular Js.

Contact Us

Email Us - gurujipoints@gmail.com
Contact- 8077657477

Reach Us

Copyright © Guruji Point - Code You Want To Write