Question: hello i was wondering if it was possible to retrieve the :id (the primary key that auto-increments in the db) after it gets saved? i have in my favorite\_relationships controller

```
def create
    @lesson = Lesson.find(params[:favorite_relationship][:lesson_id])
    current_user.favorite!(@lesson)
    #params[:id] = ...
    respond_to do |format|
      format.html { redirect_to @lesson }
      format.js
    end
end

```

when current\_user.favorite! gets called, it goes to my user model

```
  def favorite!(lesson)
    favorite_relationships.create!(lesson_id: lesson.id)
  end

```

however, is there a way to retrieve the :id the favorite\_relationship is getting saved as? i wanted to set it in the commented out line

```
#params[:id] = 

```

i need to specify a params[:id] for a gem im using

thanks

Answer: 
The problem is here `/\\/*\*\*([^\*]|\*(?!/))*\\*/g`, when you used the `\\` and then used `/`. The program understands that your regex is like this `/\\/` and what comes after results in an error. Try this regex:

```
/\/*\*\*([^\*]|\*(?!\/))*\\*/g

```

Or, depending on what you want:

```
/\\\/*\*\*([^\*]|\*(?!\/))*\\*/g

```
The [`replace()` method](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace) needs a string as a second parameter. The [patterns in it to be replaced with captures](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter) need to be in that string.

You try to build that string out of two string literals and a variable named "`$&`". Yet, that is an illegal name - the "`&`" is a [bitwise AND operator](https://developer.mozilla.org/en/JavaScript/Reference/Operators/Bitwise_Operators) and ~~lacks a second operand, because it is followed by "`+`" - SyntaxError.~~ will produce an horrible runtime error.

Also, as @FelixKling mentioned, your regexp is badly escaped. It might should be something like `new Regexp("\\/*\*\*([^\*]|\*(?!/))*\\*", "g")`, yet then there were some useless backslashes. What do you want to approach? Is it `/\*{3}([^*]|\*(?!\/))\**/g`?