Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you match multiple lines with dot (DOTALL) in eclipse find regex

I would like to convert this:

  def getEmployeeReminders(employeeId: Int, page: Option[Int], pageSize: Option[Int], js_callback: Option[String]) = Action {
      val reminders = Reminder.listForOne(employeeId, page, pageSize)
      getResponse(reminders, js_callback)
    }

to this:

  def getEmployeeReminders(employeeId: Int, page: Option[Int], pageSize: Option[Int], js_callback: Option[String]) =
    Restrict(companyAdmin, new MyDeadboltHandler) {
      Action {
        val reminders = Reminder.listForOne(employeeId, page, pageSize)
        getResponse(reminders, js_callback)
      }
    }

Multiple times in eclipse scala editor.

How do you match multiple lines with a '.*' ? Also, how do you inject newline into replacement?

like image 615
Joel Avatar asked Feb 12 '23 03:02

Joel


1 Answers

You can use the (?s) inline mode modifier which will force the dot . to match newline characters as well. In your answer, you are using a negated character class so there is no need to use this modifier, and simply use \n

Find:    = (Action[^}]*})
Replace: = \n    Restrict(companyAdmin, new MyDeadboltHandler) {\n     \1}

Using the dot . instead:

Find:    (?s)= (Action.*?})
Replace: = \n    Restrict(companyAdmin, new MyDeadboltHandler) {\n     \1}
like image 199
hwnd Avatar answered Feb 15 '23 11:02

hwnd