About 5,580,000 results
Open links in new tab
  1. javascript - Regular expression for name with spaces allowed in between ...

    May 12, 2017 · I would say a name is a sequence of alphabetic chars delimited by spaces or dots, which can be defined by the following regex: ^[a-zA-Z]+(?:[\s.]+[a-zA-Z]+)*$ Demo: https://regex101.com/r/rH5jtc/2

  2. Javascript Regular Expression "Single Space Character"

    It is perfectly legal to include a literal space in a regex. However, it's not equivalent - \s will include any whitespace character, including tabs, non-breaking spaces, half-width spaces and other characters, whereas a literal space will only match the regular space character.

  3. Regex for allowing alphanumeric,-,_ and space - Stack Overflow

    May 29, 2023 · You want to create a matching set for the characters that you want to validate: You can match alphanumeric with a \w, which is the same as [A-Za-z0-9_] in JavaScript (other languages can differ). That leaves - and spaces, which can be combined into a …

  4. Regular expression syntax cheat sheet - JavaScript | MDN - MDN Web Docs

    Oct 28, 2024 · White space character class escape: Matches a single white space character, including space, tab, form feed, line feed, and other Unicode spaces.

  5. JavaScript RegExp \s Metacharacter - W3Schools

    let text = "Is this all there is?"; The \s metacharacter matches whitespace character. Whitespace characters can be: /\s/ is an ECMAScript1 (JavaScript 1997) feature. It is supported in all browsers: In JavaScript, a regular expression text search, can be done with different methods.

  6. Regex for Name Validation in JavaScript - Tpoint Tech

    Apr 18, 2025 · In JavaScript, regex provides us with a way that we use to define patterns that the name should adhere to. For example, we want to enforce that the name only consists of alphabetic characters or they allow spaces and certain special characters like hyphens, etc.

  7. Javascript - Regex for names validation allow only letters and spaces

    Validation Regex for Names with Letters and Spaces in JavaScript: const nameRegex = /^[a-zA-Z\s]+$/; // Example usage const isValidName = nameRegex.test('Alice Wonderland'); console.log(isValidName); // true Description: This regex pattern allows only letters (both uppercase and lowercase) and spaces in a name input.

  8. Regular expressions - JavaScript | MDN - MDN Web Docs

    Jan 24, 2025 · Regular expressions are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects. These patterns are used with the exec() and test() methods of RegExp, and with the match(), matchAll(), replace(), replaceAll(), search(), and split() methods of String.

  9. javascript - regular expression to match name with only one spaces

    Aug 8, 2017 · I have a string condition in js where i have to check whether name entered in text box contains with one space only. pattern: name.status === 'full_name' ? /^[a-zA-Z.+-.']+\s+[a-zA-Z.+-. ']+$/ : /^[a-zA-Z.+-. ']+$/ But the above regex matches names ending with 2 spaces also.

  10. Regex to replace multiple spaces with a single space

    We can use a regular expression (regex) combined with JavaScript's replace() method to effortlessly eliminate those surplus spaces! 💪🚀. By using the regex /\s+/g, we're targeting any consecutive whitespace characters \s+ in the text. The g flag ensures that all occurrences are replaced, not just the first one.

  11. Some results have been removed