regex to match any 1+ non-blankspace character [duplicate] - javascript

This question already has answers here:
Reference - What does this regex mean?
(1 answer)
Using explicitly numbered repetition instead of question mark, star and plus
(4 answers)
Match exact string
(3 answers)
Closed 4 years ago.
I need to have a Regex for matching a single (or greater) non- blank space character (would allow all special characters such as !,' etc...). Would
var filter = /\S+/;
be sufficient? This seems to work for 1 or greater.
Would:
var filter = /\S+/{3,};
be sufficient for 3 or more of the non-same characters (like "def", "a!c", "dA!!f", but not "some bird"?

Related

Regex for allowing Numeric, alphabet, hyphen(-) space and apostrophes(') [duplicate]

This question already has answers here:
REGEX - Allow Numbers and . - /
(7 answers)
Closed 2 years ago.
Currently I have a textbox that accepts only Alphabet, hyphens(-), space and apostrophes('). Now I would like to add numeric values as well to it. Currently I am using the Regex as below:
/^[a-zA-ZÀ-ÖØ-öø-ÿ' -]+$/
How would I achieve adding numerics as well to the above?
To allow numbers, simply add 0-9 in your regex, like so:
/^[0-9a-zA-ZÀ-ÖØ-öø-ÿ' -]+$/

Regular expression for checking extra space(more than one) in middle of words [duplicate]

This question already has answers here:
How to search for occurrences of more than one space between words in a line
(5 answers)
Closed 3 years ago.
Currently I'm using regex=/^(\w+\s?)*\s*$/, it's working fine for extra space, but failing for special characters.
Expectation:
regex.test('abcd ghh') => false
regex.test('abcd*') => true
You will need the last regex pattern of this solution.
[^\s]([ ]{2,})[^\s]

regular expression javascripy [duplicate]

This question already has answers here:
Regex to validate password strength
(11 answers)
Closed 4 years ago.
What can be a valid regex for a password that contains at least 8 characters in which there should be one upper-case,one lower-case and one number?
Here is a regular expression for a string with at least 8 characters, one upper-case, one lower-case and one number.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$

Regex working in every online parser but not in JS? [duplicate]

This question already has answers here:
Why do regex constructors need to be double escaped?
(5 answers)
Regex created via new RegExp(myString) not working (backslashes)
(1 answer)
Javascript RegEx Not Working [duplicate]
(1 answer)
Closed 5 years ago.
I've created regex to parse football match score:
(0|[1-9]\d*\s)(:)(\s0|[1-9]\d*)
When I try:
let scoreRegex = new RegExp('(0|[1-9]\d*\s)(:)(\s0|[1-9]\d*)')
scoreRegex.exec('Team One 5 : 0 Team Two')
I get null instead of expected 3 groups. Any online parser out there validates my regex and matches the input string.
https://www.regextester.com/ +
https://regexr.com/ +
What am I missing?

AngularJS alpha only regex is accepting special characters [duplicate]

This question already has answers here:
I want to ignore square brackets when using javascript regex [duplicate]
(4 answers)
Closed 8 years ago.
I have a very simple form with this regex pattern set on my first/last name fields ng-pattern="/^[a-zA-z]{2,30}$/" and both fields accept this value as being valid e.g. Tester\^*&^%. The first/last name should only accept alpha character a-zA-Z with a minimum of 2 characters and a max of 30.
Here is the wrong thing.
^[a-zA-z]{2,30}$
^
|
It would match \^ symbols because these symbols are comes under the range from A to z.
Modified regex.
^[a-zA-Z]{2,30}$

Categories