简体   繁体   English

在函数内部搜索并用正则表达式和崇高文本替换

[英]Search and replace inside a function with regex and sublime text

Is there a way to use regex locating the second input (after comma) inside a php function and and use replace to remove it? 有没有办法使用正则表达式在php函数中定位第二个输入(逗号后),然后使用replace删除它?

I would like to use this in sublime text to remove an input field inside a function that is used across many pages. 我想在崇高的文本中使用它来删除跨多个页面使用的函数内的输入字段。

I want this function: 我想要这个功能:

LoggFor ($brukerid, $dato, $sysreg, $dat_1 = '', $dat_2 = '', $dat_3 = '', $dat_4 = '', $dat_5 = '', $dat_6 = '', $dat_7 = '')

To be replaced with: 替换为:

LoggFor ($brukerid, $sysreg, $dat_1 = '', $dat_2 = '', $dat_3 = '', $dat_4 = '', $dat_5 = '', $dat_6 = '', $dat_7 = '')

The problem is that the input across many different pages is not as mentioned above. 问题在于跨许多不同页面的输入不像上面提到的那样。 In other words, I want to remove 2nd input from all functions regardless of variable name. 换句话说,我想从所有函数中删除第二个输入,而不管变量名如何。

Screenshot from Sublime Text: Sublime Text的屏幕截图: 在此处输入图片说明

Use 采用

LoggFor\s*\([^),]*\K,\s*[^,)]*

Replace with an empty string. 替换为空字符串。

Details 细节

  • LoggFor - a literal substring LoggFor文字子字符串
  • \\s* - 0+ whitespaces \\s* -0+空格
  • \\( - a ( \\( -一个(
  • [^),]* - zero or more chars other than ) and , [^),]* -零个或多个字符以外),
  • \\K - match reset operator (all text matched up to this place is omitted from the match and thus, it will remain) \\K匹配重置运算符(匹配到此位置的所有文本都将从匹配中省略,因此将保留)
  • , - a comma , -逗号
  • \\s* - 0+ whitespaces \\s* -0+空格
  • [^,)]* - zero or more chars other than ) and , [^,)]* -零个或多个字符,但不包括),

See the screenshot with settings: 查看带有设置的屏幕截图:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM