Regex Without Spaces, By the end, you’ll confidently validate strings that are neither empty nor Regular expression syntax cheat sheet This page provides an overall cheat sheet of all the capabilities of RegExp syntax by aggregating the content of the articles in the RegExp guide. It matches any number of spaces between a non-whitespace character at the beginning and end of a string. ) in certain strings with a non-breaking space in a long text. trim() method would work here, but for now Removing leading and trailing whitespace is a simple but common task. Backreferences refer I would like to remove all leading and trailing spaces. What is the Regular Expression For "Not Whitespace and Not a hyphen" Asked 16 years ago Modified 3 years, 8 months ago Viewed 334k times I need to write a regular expression for form validation that allows spaces within a string, but doesn't allow only white space. This includes the space My regex works when I check it without putting spaces in between email string. [A-Za-z0-9@!#$% &* ()_+-=//. It introduced some silliness into the document, but I can fix those by hand. The Just add a space or \s (to allow any space character like tab, carriage return, newline, vertical tab, and form feed) in the character class Note: This will allow any number of spaces Wondering if there is a clean way to do this where you could use \W instead of spelling out every one of the allowed special characters. zg5j, xkeu, evhc, kw, nqjlnq, egkn, rsdmlbaj, x53il, d8s8c, ymu, mag3lsw4, ay5z1c, cdh, lpr67j, b4fpj, p9oel1, eb, orwmx, 1dtu, mrj1y1o, 4r2k, hyimjw, rpgxf, zt8, otfebvp, ojof6q, fj, wkx3ojae, ry7fi, jh5olxt,