Skip to content

Regex functions throw errors #440

Open

Description

@mrdziuban

Regex.replace/4, Regex.match?/2, and String.replace/4 throw the following error in the browser:

TypeError: Cannot read property 'run' of undefined

while trying to call

ElixirScript.Core.re.run

See here for a repository that demonstrates the issue: https://github.com/mrdziuban/elixirscript_test.

You can also go to http://mattdziuban.com/elixirscript_test/ and click the buttons to see the error and stack trace.

Activity

  1. bryanjos commented on Dec 9, 2017

    @bryanjos
    Collaborator

    This has to do with the :re module not being implemented yet. Issue #306 catalogs what erlang modules and functions need to be implemented

  2. mrdziuban commented on Dec 11, 2017

    @mrdziuban
    ContributorAuthor

    Thanks for the info. I started implementing :re.run but got stuck trying to decipher the javascript representation of the regex object. The elixir code is:

    Regex.replace(~r/foo/i, "hello foo", "world")

    and the regex in run looks like this:

    function run(subject, regex, options) {
      console.log(regex)
      // => Tuple {values: Array(5), length: 5}
      console.log(regex.values)
      // => [Symbol(re_pattern), 0, 0, 0, "ERCPM�������������������f�o�������@�������������������������������	�f�o�ox�	�"]
    }

    Any idea how I can extract a meaningful value from that? Thanks in advance.

  3. bryanjos commented on Dec 12, 2017

    @bryanjos
    Collaborator

    That's odd. Nothing off the top of my head. That must be the binary representation. It's possible the BitString JavaScript module may be able to make something out of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions