RegexRedaction
Leave feedback
On this page
Represents a text redaction that searches and replaces text in the document by matching provided regular expression.
public class RegexRedaction : TextRedaction
| Name | Description |
|---|---|
| RegexRedaction(Regex, ReplacementOptions) | Initializes a new instance of RegexRedaction class. |
| RegexRedaction(string, ReplacementOptions) | Initializes a new instance of RegexRedaction class. |
| Name | Description |
|---|---|
| ActionOptions { get; } | Gets the ReplacementOptions instance, specifying type of text replacement. |
| override Description { get; } | Returns a string, describing the redaction and its parameters. |
| OcrConnector { get; set; } | Gets or sets the IOcrConnector implementation, required to extract text from graphic content. |
| RegularExpression { get; } | Gets the regular expression to match. |
| Name | Description |
|---|---|
| override ApplyTo(DocumentFormatInstance) | Applies the redaction to a given format instance. |
Learn more
- More details about applying redactions: Redaction basics
- More details about document text redactions: Text redactions
The following example demonstrates replacing text using the regular expression.
using (Redactor redactor = new Redactor(@"C:\sample.pdf"))
{
// replace with text
redactor.Apply(new RegexRedaction("\\d{2}\\s*\\d{2}[^\\d]*\\d{6}", new ReplacementOptions("[removed]")));
// replace with blue solid rectangle
redactor.Apply(new RegexRedaction(@"^\d+[,\.]{1}\d+$", new ReplacementOptions(System.Drawing.Color.Blue)));
redactor.Save();
}
- class TextRedaction
- namespace GroupDocs.Redaction.Redactions
- assembly GroupDocs.Redaction
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.