Skip to content

regexp: simple Ruby regular expression doesn’t work #3451

Closed
@gopherbot

Description

@gopherbot

by blake.mizerany:

I’ve been slowly working on migrating more of Heroku’s codebase over to Go. One of
my more Ruby-centric coworkers just wasted several hours today on Go’s lack of support
for this regular expression:

    var validRequest = regexp.MustCompile(`^/customer/(\w+)/(\w+)?authas=\1(&.*)?`)

After tweaking, I’ve narrowed it down to this minimal repro case:

   var r = regexp.MustCompile(`^(a).+\1`)

That works fine in Ruby:

$ irb
>> "abba".match(/^(a).+\1/)
=> #<MatchData "abba" 1:"a">

Why doesn’t this work in Go?

Not to look a gift horse in the mouth, but I’ll have a harder time getting co-workers
to adopt Go if such basic things from Ruby aren’t even supported.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions