在eclipse find regex中如何匹配多行(DOTALL) [英] How do you match multiple lines with dot (DOTALL) in eclipse find regex

查看:164
本文介绍了在eclipse find regex中如何匹配多行(DOTALL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转换:

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

到:

  def getEmployeeReminders(employeeId:Int,page:Option [Int],pageSize:Option [Int],js_callback:Option [String])= 
限制(companyAdmin,new MyDeadboltHandler){
Action {
val提醒= Reminder.listForOne(employeeId,page,pageSize)
getResponse(提醒,js_callback)
}
}
pre>

在eclipse scala编辑器中多次使用。



如何使用'。*' ?
另外,如何将换行符注入替换?

解决方案

您可以使用内嵌模式修饰符,这将强制点也匹配换行符。在您的答案中,您使用的是否定角色类,因此无需使用此修饰符,只需使用 \\\

  Find:=(Action [^}] *})
替换:= \\\
限制(companyAdmin,new MyDeadboltHandler){\\\
\1 }

使用点 / p>

 查找:(?s)=(Action。*?})
替换:= \\\
限制(companyAdmin ,新的MyDeadboltHandler){\\\
\1}


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?

解决方案

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}

这篇关于在eclipse find regex中如何匹配多行(DOTALL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆