打破字符串并将部分打到最后

时间:2017-07-10 11:32:04

标签: regex sed

我正在使用sed命令查找/controller which is a word/action

"href="/bdgp/bdgp-record-com1-form?type=R&year=<?php echo $year;?>&batchNumber=<?php echo $this->escapehtml($animal->BATCH_NUMBER);?> " 

会改变结果......

href="<?php echo $this->url("bdgp", array("action"=>"bdgp-record-com1-form"))?>?type=R&year=<?php echo $year;?>&batchNumber=<?php echo $this->escapehtml($animal->BATCH_NUMBER);?>

这是我正在使用的sed命令,它找到像/ anything / anything / anything

这样的模式
sed -i 's%href=\"\/\([^/]*\)\/\([^/]*\)?\([^/]*\)%href=\"<?php echo $this->url(\"\1\", array(\"action\"=>\"\2\"))?> \"<%g' changes.txt;

我得到的是这个......

href="<?php echo $this->url("bdgp", array("action"=>"bdgp-record-com1-form?type=R&year=<?php echo $year;?>&batchNumber=<?php echo $this->escapehtml($animal->BATCH_NUMBER);?>

如何从结果中提取出?type = R&amp; year =&amp; batchNumber = escapehtml($ animal-&gt; BATCH_NUMBER);?&gt;并把它放在最后?

由于

0 个答案:

没有答案