Apparently, back in Firefox 3.6, the following was legitimate:
/[0-9]{3}/('23 2 34 678 9 09')
and the result was '678'.
FF8 isn't having any. What's the right syntax now?
In JavaScript, you can use regular expressions with RegExp() methods: test() and exec() . There are also some string methods that allow you to pass RegEx as its parameter. They are: match() , replace() , search() , and split() . Executes a search for a match in a string and returns an array of information.
Regular expressions are a sequence of characters that are used for matching character combinations in strings for text matching/searching. In JavaScript, regular expressions are search patterns (JavaScript objects) from sequences of characters. RegExp makes searching and matching of strings easier and faster.
sub() function belongs to the Regular Expressions ( re ) module in Python. It returns a string where all matching occurrences of the specified pattern are replaced by the replace string. To use this function, we need to import the re module first.
Do you want
/[0-9]{3}/.test('23 2 34 678 9 09');
or
/[0-9]{3}/.exec('23 2 34 678 9 09');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With