ragulka
ragulka

Reputation: 4342

Convert PHP preg_match to javascript

can somebody help me converting this

preg_match('/^(.*?)[#,\.0]+(.*?)$/',$patterns[0],$matches)

into Javascript equivalent? I tried doing

matches = patterns[0].match('/^(.*?)[#,\.0]+(.*?)$/')

but this results in null...

Upvotes: 1

Views: 3815

Answers (1)

Andreas
Andreas

Reputation: 21911

Remove the quotes from the regex

matches = patterns[0].match(/^(.*?)[#,\.0]+(.*?)$/);

Upvotes: 8

Related Questions