首先,正则表达式很可能是我处理过的最令人困惑的事情 - 话虽这么说,我不敢相信它们能如此高效。
所以我想在运气不好的情况下理解通配符正则表达式
需要转
f_firstname
f_lastname
f_dob
f_origincountry
f_landing
进入
':f_firstname'=>$f_firstname,
':f_lastname'=>$f_lastname,
':f_dob'=>$f_dob,
':f_origincountry'=>$f_origincountry,
':f_landing'=>$f_landing,
在回答中,您能否简要描述一下您正在使用的正则表达式,我一直在阅读教程,但它们让我感到困惑。谢谢。
最佳答案
编辑:正如克里斯指出的那样,您可以通过清除目标字符串中可能存在的任何空白来改进正则表达式。我也像他一样用 \w
替换了圆点,因为这比使用 更好。
Search: ^f_(\w+)\s*$
^ # start at the beginning of the line
f_ # look for f_
(\w+) # capture in a group all characters
\s* # optionally skip over (don't capture) optional whitespace
$ # end of the line
Replace: ':f_\1'=>$f_\1,
':f_ # beginning of replacement string
\1 # the group of characters captured above
'=>$f_ # some more characters for the replace
\1, # the capture group (again)
关于regex - Notepad++ 正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12233815/