MBRegexParser


@interface MBRegexParser : MBParser <NSCopying>

Represents a parser which parses OCR result according to given regular expression. Regular expression parsing is not performed with java’s regex engine. Instead, it is performed with custom regular expression engine which can work with multiple char recognition alternatives (if enabled in MBBaseOcrEngineOptions). Due to differences between parsing normal strings and OCR results, this parser does not support some regex features found in java’s regex engine, like back references.

  • Undocumented

    Declaration

    Objective-C

    MB_INIT_UNAVAILABLE
  • Initializes the regex parser

    Declaration

    Objective-C

    - (nonnull instancetype)initWithRegex:(nonnull NSString *)regex;

    Swift

    init(regex: String)

    Parameters

    regex

    regular expression pattern for extraction

  • Regex parser result

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) MBRegexParserResult *_Nonnull result;

    Swift

    var result: MBRegexParserResult { get }
  • Defines regex that will be used to parse OCR data. Note that not all java regex features are available, such as back references and ‘^’ and ‘$’ meta-character. ‘.’ meta-character that represents any character and ‘^’ inside brackets representing all characters except those in brackets are available only if alphabet is defined.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) NSString *_Nonnull regex;

    Swift

    var regex: String { get set }
  • Enable the usage of algorithm for combining consecutive OCR results between video frames for improving OCR quality. By default this is turned off.

    Note: This option works together only with if instance of {@link com.microblink.entities.ocrengine.legacy.BlinkOCREngineOptions} is given to {@link #setOcrEngineOptions(com.microblink.entities.ocrengine.AbstractOCREngineOptions)}. Otherwise, it will not be enabled and {@link IllegalArgumentException} will be thrown.

    Default: NO

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL useSieve;

    Swift

    var useSieve: Bool { get set }
  • If set to YES, regex will not be matched if there is no whitespace before matched string. Whitespace is not returned in parsed result.

    Default: NO

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL startWithWhitespace;

    Swift

    var startWithWhitespace: Bool { get set }
  • If set to YES, regex will not be matched if there is no whitespace after matched string. Whitespace is not returned in parsed result.

    Default: NO

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL endWithWhitespace;

    Swift

    var endWithWhitespace: Bool { get set }
  • Sets the OCR engine options used in Regex OCR parser. Returns the OCR engine options used in Regex OCR parser.

    Default: default instance of MBOcrEngineOptions

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic)
        MBBaseOcrEngineOptions *_Nonnull ocrEngineOptions;

    Swift

    var ocrEngineOptions: MBBaseOcrEngineOptions { get set }