Skip to content

repl cannot handle single quote in regex, when within a function #5113

Closed

Description

@phillipwei

I'm getting a 'SyntaxError: Unexpected end of input' when I try to enter the following in the repl

var someFunction = function(s) {
    s = s.replace(/'/g, '');
}

However, s = s.replace(/'/g, '') by itself on a new line is OK. Am I doing something wrong?

Activity

  1. added
    replIssues and PRs related to the REPL subsystem.
    on Feb 6, 2016
  2. Trott commented on Feb 6, 2016

    @Trott
    Member

    This is indeed a bug, and you're not doing anything wrong. For a quick workaround, you can use a backslash to escape the single quote in the regular expression: s=s.replace(/\'/g, '');

    But yes, you shouldn't have to do that.

  3. phillipwei commented on Feb 6, 2016

    @phillipwei
    Author

    Thanks for the work around!

  4. silverwind commented on Feb 10, 2016

    @silverwind
    Contributor

    Fixed in 211018f!

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

    confirmed-bugIssues and PRs for confirmed bugs.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions