Hi scottr,
patterns are supposed to go trough a whole text. often you will find yourself wanting several matches from the same document. For example you want to find all occurences off a misspelled word, to correct it. Basically, if you want to limit matching to a string of three digits only, you could do the following: /^\d{3}$/
If you only want to find 3 digit numbers in a longer text, use: /(?<!\d)\d{3}(?!\d)/
If they are just separated by whitespace, use /(?<=\s)\d{3}(?=\s)/
There is a quite good explanation about regex in Professional javascript for web developers by wrox.
|