How to use the talisman/regexp.escapeRegexp function in talisman

To help you get started, we’ve selected a few talisman 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 medialab / aime-core / interfaces / admin / js / components / linkSelector.jsx View on Github external
searchItems() {
    const query = this.state.search;

    if (!query || query.length < 3)
      return this.setState({filteredItems: []});

    const regex = new RegExp(escapeRegexp(query).replace(/\s/g, '\\s'), 'i');

    const filteredItems = (this.props.paragraphs || [])
      .filter(data => {
        return regex.test(data.paragraph.text);
      });

    return this.setState({filteredItems: filteredItems});
  }
github medialab / aime-core / interfaces / admin / js / components / linkSelector.jsx View on Github external
searchItems() {
    const query = this.state.search;

    if (!query || query.length < 3)
      return this.setState({filteredItems: []});

    const regex = new RegExp(escapeRegexp(query).replace(/\s/g, '\\s'), 'i');

    const filteredItems = (this.props.voc || [])
      .filter(voc => {
        if (regex.test(voc.title))
          return true;

        return voc.children.some(paragraph => {
          return regex.test(paragraph.text);
        });
      });

    return this.setState({filteredItems: filteredItems});
  }