ByteScout Sensitive Data Suite - C# - Remove Sensitive Text Using Regex Expressions - ByteScout

ByteScout Sensitive Data Suite – C# – Remove Sensitive Text Using Regex Expressions

  • Home
  • /
  • Articles
  • /
  • ByteScout Sensitive Data Suite – C# – Remove Sensitive Text Using Regex Expressions

How to remove sensitive text using regex expressions in C# with ByteScout Sensitive Data Suite

Learning is essential in computer world and the tutorial below will demonstrate how to remove sensitive text using regex expressions in C#

The sample source code below will teach you how to remove sensitive text using regex expressions in C#. ByteScout Sensitive Data Suite: the set that includes SDK tools from ByteScout for working with sensitive and personal data. With these tools you may analyze, redact, remove, blackout sensitive data in documents and pdf. It can remove sensitive text using regex expressions in C#.

This prolific sample source code in C# for ByteScout Sensitive Data Suite contains various functions and other necessary options you should do calling the API to remove sensitive text using regex expressions. Follow the instructions from scratch to work and copy the C# code. Enjoy writing a code with ready-to-use sample codes in C#.

Trial version of ByteScout Sensitive Data Suite is available for free. Source code samples are included to help you with your C# app.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System; using System.Drawing; using Bytescout.PDFExtractor; namespace RemoveSensitiveTextUsingRegexExpressions { class Program { static void Main(string[] args) { // Create Bytescout.PDFExtractor.Remover instance Remover remover = new Remover("demo", "demo"); // Load sample PDF document remover.LoadDocumentFromFile(@"samplePDF_EmailAddress.pdf"); // Prepare TextExtractor using (TextExtractor textExtractor = new TextExtractor("demo", "demo")) { // Load document into TextExtractor textExtractor.LoadDocumentFromFile(@"samplePDF_EmailAddress.pdf"); // Search email Addresses // See the complete regular expressions reference at https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx string regexPattern = @"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b"; // Enable RegexSearch textExtractor.RegexSearch = true; // Set word matching options textExtractor.WordMatchingMode = WordMatchingMode.None; ISearchResult[] searchResults = textExtractor.FindAll(0, regexPattern, caseSensitive: false); // Remove text objects find by SearchResults. // NOTE: The removed text might be larger than the specified rectangle. Currently the Remover is unable // to split PDF text objects. remover.RemoveText(searchResults, @"result1.pdf"); } // Open output file in default application System.Diagnostics.Process.Start("result1.pdf"); // Clean up. remover.Dispose(); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Sensitive Data Suite Home Page

Explore ByteScout Sensitive Data Suite Documentation

Explore Samples

Sign Up for ByteScout Sensitive Data Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Sensitive Data Suite Home Page

Explore ByteScout Sensitive Data Suite Documentation

Explore Samples

Sign Up for ByteScout Sensitive Data Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

prev
next