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

Is there a way to use regex locating the second input (after comma) inside a php function and and use replace to remove it?

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: enter image description here

Use

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

Replace with an empty string.

Details

  • LoggFor - a literal substring
  • \s* - 0+ whitespaces
  • \( - 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)
  • , - a comma
  • \s* - 0+ whitespaces
  • [^,)]* - zero or more chars other than ) and ,

See the screenshot with settings:

enter image description here