如何在日食查找正则表达式中用点(DOTALL)匹配多行

Joe*_*oel 3 regex eclipse multiline

我想将其转换为:

  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)
    }
Run Code Online (Sandbox Code Playgroud)

对此:

  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)
      }
    }
Run Code Online (Sandbox Code Playgroud)

在Eclipse Scala编辑器中多次。

如何将多个行与'。*'匹配?另外,您如何将换行符替换?

hwn*_*wnd 5

您可以使用(?s)内联模式修饰符,该修饰符将强制点.也匹配换行符。在您的答案中,您使用的是否定字符类,因此无需使用此修饰符,只需使用\n

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

使用点.代替:

Find:    (?s)= (Action.*?})
Replace: = \n    Restrict(companyAdmin, new MyDeadboltHandler) {\n     \1}
Run Code Online (Sandbox Code Playgroud)