Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex functions throw errors #440

Open
mrdziuban opened this issue Dec 8, 2017 · 3 comments
Open

Regex functions throw errors #440

mrdziuban opened this issue Dec 8, 2017 · 3 comments

Comments

@mrdziuban
Copy link
Contributor

@mrdziuban mrdziuban commented Dec 8, 2017

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.

@bryanjos
Copy link
Collaborator

@bryanjos bryanjos commented Dec 9, 2017

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

@mrdziuban
Copy link
Contributor Author

@mrdziuban mrdziuban commented Dec 11, 2017

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.

@bryanjos
Copy link
Collaborator

@bryanjos bryanjos commented Dec 12, 2017

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.