phpjavascriptphpjs

JavaScript equivalent of PHP preg_split()


Is there an equivalent of the PHP function preg_split for JavaScript?


Solution

  • Any string in javascript can be split using the string.split function, e.g.

    "foo:bar".split(/:/)
    

    where split takes as an argument either a regular expression or a literal string.