小编rba*_*kar的帖子

sed multiline替换

这是我的示例文本文件:

asdas
//<<<TAG
this should be removed
//TAG>>>
this should be there
//<<<TAG
T
>
asd
asd
//TAG>>>

我希望o/p为:

asdas

this should be there

基本上我试图找到"// << >>"之间的行(包括这些行)并删除它们.

我尝试使用sed

sed -n'1h; 1!H; $ {; g; s /// <<]*TAG >>> // g; p;}'<test.txt

但有些人如何没有产生正确的输出.正则表达式中包含">"符号的第二个标记失败.不知道我哪里出错了?

知道怎么做吗?

sed multiline

15
推荐指数
1
解决办法
2万
查看次数

防止json_encode关联数组排序

我有一个关联数组

Array(
   [289] => Array(
    'name'=> 'One'
   ),
   [292] => Array(
    'name'=> 'One'
   ),
   [290] => Array(
    'name'=> 'One'
   )
)
Run Code Online (Sandbox Code Playgroud)

我在这个数组上使用json_encode之后.键被排序,虽然我把它作为JSON对象.

有办法防止这种行为吗?

php json associative-array

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

associative-array ×1

json ×1

multiline ×1

php ×1

sed ×1