Hello (my first entry) ! I have a problem with regular expression. I am trying to specify a pattern to make sure the inputted data is one word (string of characters ranging from A-Za-z - never mind the ÅÄÖ and the åäö (Swedish signs)) followed by a space and a number with 1 to 4 digits. My current code: pattern = /^([A-ZÅÄÖa-zåäö])+([\s]?)+([\d{1,4}])+$/; I have also tried (which is proposingly the same thing): pattern = = /^([A-ZÅÄÖa-zåäö])+([\s]?)+([0-9]{1,4})+$/; Unfortunately this does not work. It does make sure I have a space and atleast one digit but it does not limit the number to have at most 4 digits. I have searched for some time and I can´t find any good example to a solution. Most articles of regular expressions in javascript seem to be theoretical. But according to javascriptkit.com () I should use the quantifier {n,m} to "{n,m} matches n to m times". Solution?
Sometimes the answer is right in front of you. All you need to do is ask someone else to realize it yourself: Solution: Remove the last '+'. pattern = = /^([A-ZÅÄÖa-zåäö])+([\s]?)+([0-9]{1,4})$/; Thanks anyway!
An example JavaScript code you should view to understand Regular expression clearly. http://javascriptbank.com - place can solve all JavaScript problems for you