如何将以下匹配转换为给定结果?
我的文件有以下匹配项
-- cut --
Lorem ipsun Hello lorem ipsun { $hello }
@param integer $question_id // example of the match
Lorem ipsun Hello lorem ipsun { $hello }
-- cut --
Run Code Online (Sandbox Code Playgroud)
我想有效地改变它们
@param $question_id integer
Run Code Online (Sandbox Code Playgroud)
我在伪代码中的尝试
perl -i.bak -pe `s/(@param) (\\w) ($\\w)/$1 $3 $2/`
Run Code Online (Sandbox Code Playgroud)
你的意思是(假设bash shell):
perl -i.bak -pe 's/(\@param) (\w+) (\$\w+)/$1 $3 $2/'
Run Code Online (Sandbox Code Playgroud)