How to use the @microsoft/recognizers-text.RegExpUtility.getMatchEnd function in @microsoft/recognizers-text

To help you get started, we’ve selected a few @microsoft/recognizers-text examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseDate.ts View on Github external
matches.forEach(match => {
                // @TODO Implement validateMatch as in .NET
                let preText = source.substring(0, match.index);
                let relativeRegex = RegExpUtility.getMatchEnd(this.config.strictRelativeRegex, preText, true);
                if (relativeRegex.success) {
                    ret.push(new Token(relativeRegex.match.index, match.index + match.length));
                }
                else {
                    ret.push(new Token(match.index, match.index + match.length));
                }

            });
        });
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseDate.ts View on Github external
this.config.dateRegex.some(regex => {
            let offset = 0;
            let relativeStr = null;
            let match = RegExpUtility.getMatches(regex, trimmedSource).pop();
            if (!match) {
                match = RegExpUtility.getMatches(regex, this.config.dateTokenPrefix + trimmedSource).pop();
                if (match) {
                    offset = this.config.dateTokenPrefix.length;
                    relativeStr = match.groups('order').value;
                }

            }
            if (match) {
                let relativeRegex = RegExpUtility.getMatchEnd(this.config.strictRelativeRegex, source.substring(0, match.index), true);
                let isContainRelative = relativeRegex.success && match.index + match.length === trimmedSource.length;
                if ((match.index === offset && match.length === trimmedSource.length) || isContainRelative) {

                    if (match.index !== offset) {
                        relativeStr = relativeRegex.match.value;
                    }
                    result = this.matchToDate(match, referenceDate, relativeStr);
                    return true;
                }
            }
        });
        return result;