Webflags: u

Slug (Unicode Letters Allowed)

Validate URL slugs allowing Unicode letters (`café-rénové`), as supported by Next.js i18n routing.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("^[\\p{L}\\p{N}]+(?:-[\\p{L}\\p{N}]+)*$", "u");
const input = "hello-world";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
^[\p{L}\p{N}]+(?:-[\p{L}\p{N}]+)*$   (flags: u)

Raw source: ^[\p{L}\p{N}]+(?:-[\p{L}\p{N}]+)*$

How it works

[\p{L}\p{N}]+ matches one or more Unicode letters or numbers (so `café` and `東京` are valid). (?:-[\p{L}\p{N}]+)* allows additional hyphen-separated segments. The u flag is REQUIRED in JavaScript for \p{} property escapes; Python's stdlib `re` doesn't support \p{} (use \w with Unicode flag, or the `regex` package); Go RE2 has its own \p{...} support.

Examples

Input

hello-world

Matches

  • hello-world

Input

café-rénové

Matches

  • café-rénové

Input

trailing-

No match

Common use cases

  • i18n slug validation in Next.js routing
  • Content-management systems serving non-Latin markets
  • URL safety enforcement for user-generated content
  • Auto-slug generation guards

Related patterns