RegexRedaction
Contents
[
Hide
]
RegexRedaction class
Represents a text redaction that searches and replaces text in the document by matching provided regular expression.
public class RegexRedaction : TextRedaction
Constructors
| Name | Description |
|---|---|
| RegexRedaction(Regex, ReplacementOptions) | Initializes a new instance of RegexRedaction class. |
| RegexRedaction(string, ReplacementOptions) | Initializes a new instance of RegexRedaction class. |
Properties
| 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. |
Methods
| Name | Description |
|---|---|
| override ApplyTo(DocumentFormatInstance) | Applies the redaction to a given format instance. |
Remarks
Learn more
- More details about applying redactions: Redaction basics
- More details about document text redactions: Text redactions
Examples
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();
}
See Also
- class TextRedaction
- namespace GroupDocs.Redaction.Redactions
- assembly GroupDocs.Redaction