How to use the xregexp/xregexp-all.js.exec function in xregexp

To help you get started, we’ve selected a few xregexp 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 Human-Connection / Human-Connection / webapp / middleware / searchHashtag.js View on Github external
export default async ({ store, env, route, redirect }) => {
  let publicPages = env.publicPages
  // only affect non public pages
  if (publicPages.indexOf(route.name) >= 0) {
    return true
  }

  const regX = build('^/search/hashtag/((\\pL+[\\pL0-9]*)|([0-9]+\\pL+[\\pL0-9]*))$')
  const matchHashtag = route.fullPath ? exec(decodeURI(route.fullPath), regX) : null

  if (!matchHashtag) return true

  return redirect(`/?hashtag=${encodeURI(matchHashtag[1])}`)
}
github Human-Connection / Human-Connection / backend / src / middleware / hashtags / extractHashtags.js View on Github external
urls.forEach(url => {
    const match = exec(url, regX)
    if (match != null) {
      hashtags.push(match[1])
    }
  })
  return hashtags