Regex 101 Discussion I4 - remove unprintable characters from a string

Posted by: Eric Gunnersons C# Compendium, on 23 Jan 2006 | View original | Bookmarked: 0 time(s)

Exercise I4 - remove unprintable characters from a string

Given an input string, remove all characters that are not printable.

--------------

Assuming ASCII - or something like ASCII - non-printing characters have ascii values of 31 or lower. You can match them with the following:

           [\x01-\x1F]

and then user Regex.Replace() to replace each of those characters with an empty string.

Category: Regex | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 5655 | Hits: 165

Similar Posts

  • Lookbehind in Regex searches more
  • Filtering with string parameter that allows free user input more
  • LINQ Tip of the week: System.String support more
  • Url.Action() and RouteValue Encoding more
  • Validation - Part 2 - Client-Side more
  • Validation - Part 1 - Getting Started more
  • ORM Release History : Q1 2009 SP1 (version 2009.1.405.1) more
  • Using Enums in List Controls more
  • Background: Extension Methods, Silverlight & Linq more
  • Named Formats Redux more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD