'Regex for no leading and trailing space only middle space in JavaScript? [duplicate]
Like tried with this sample with no special character:
let x = new RegExp('^[A-Za-z\s0-9]+$'); // with no special char
x.test('Hello world'); // should return true
x.test('Hello world with something'); // should return true
x.test(' Hello world'); // should return false
x.test('Hello world '); // should return false
x.test('Hello world'); // should return false
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
