批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[已解决]20元 bat或Powershell处理文本内容使其倒序排列

具体报酬:20元人民币
支付方式:支付宝,微信转账
联系方式:QQ296578353
有效期限:问题解决之前。WHY请联系一下我可以吗?转点小钱略表感谢。已经帮助我很多次了,而且每次给出的答案都是切实可行的。

情景再现自己写好的代码 被人抄袭套用 可气的是对方还在代码前加上“原创代码,抄袭举报” 真是此地无银三百两掩耳盗铃的小人
为了保护自身知识产权,需要一个把写好的代码中数组位置置换 去除写代码时的思路备注 去除换行符号(后边再用工具加密)

需要处理以下类似文本
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Lockscreen screenWidth="1080" frameRate="45" displayDesktop="true" scale="1*#scalescreen" pivotX="#screen_width/2" pivotY="#screen_height/2" alpha="255*#homescreen_action">
  3. <!-- Start-2019.5.12 =x=2019.5.12 -->
  4. <Button x="0" y="0" w="#screen_width" h="#screen_height" />
  5. <ExternalCommands>
  6. <Trigger action="resume">
  7. <VariableCommand name="ts" expression="0" />
  8. <VariableCommand name="Sidebar_v" expression="0" />
  9. <VariableCommand name="wallpaper_mask" expression="1" />
  10. <VariableCommand name="slider_xy_flag" expression="0" />
  11. <VariableCommand name="unlocker_flag" expression="0" />
  12. <VariableCommand name="unlocked" expression="0" />
  13. <AnimationCommand target="timemove" command="play(500,1000)" delay="0" condition="eq(#timemove,0)*#blackbg" />  
  14. <AnimationCommand target="timemove2" command="play(500,1400)" delay="0" condition="eq(#timemove2,0)*#blackbg" />
  15. <AnimationCommand target="timemove3" command="play(500,1800)" delay="0" condition="eq(#timemove3,0)*#blackbg" />
  16. <AnimationCommand target="timemove" command="play(1000,0)" delay="0" condition="eq(#timemove,0)*not(#blackbg)" />  
  17. <AnimationCommand target="timemove2" command="play(1400,0)" delay="0" condition="eq(#timemove2,0)*not(#blackbg)" />
  18. <AnimationCommand target="timemove3" command="play(1800,0)" delay="0" condition="eq(#timemove3,0)*not(#blackbg)" />
  19. <AnimationCommand target="appmove" command="play(800,0)" delay="0" condition="eq(#appmove,0)*not(#blackbg)" />               
  20. <AnimationCommand target="appalpha" command="play(0)" delay="0" condition="eq(#appalpha,0)*not(#blackbg)" />  
  21. <AnimationCommand target="bzmove" command="play" />
  22. </Trigger>
  23. <Trigger action="pause">
  24. <VariableCommand name="Sidebar_v" expression="0" />
  25. <VariableCommand name="suiji_bg" expression="ifelse(not(#Img_ID),round(rand(0)*7+1),#Img_ID)" />
  26. <AnimationCommand target="scale_charge" command="play(200,0)" condition="eq(#charge,1)"/>
  27. <AnimationCommand target="chargealpha" command="play(200,0)" condition="eq(#charge,1)"/>
  28. <AnimationCommand target="bgalpha" command="play(1800,0)"  condition="eq(#blackbg,1)" />
  29. </Trigger>
  30. </ExternalCommands>
  31. <VariableBinders>
  32. <ContentProviderBinder name="data" uri="content://keyguard.notification/notifications" columns="icon,title,content,time,info,subtext,key" countName="hasnotifications">
  33. <Variable name="notification_icon" type="blob.bitmap" column="icon" row="0" />
  34. <Variable name="notification_title" type="string" column="title" row="0" />
  35. <Variable name="notification_content" type="string" column="content" row="0" />
  36. <Variable name="notification_time" type="string" column="time" row="0" />
  37. <Variable name="notification_info" type="string" column="info" row="0" />
  38. <Variable name="notification_subtext" type="string" column="subtext" row="0" />
  39. <Variable name="notification_key" type="int" column="key" row="0" />
  40. <List name="notification_list" />
  41. </ContentProviderBinder>
  42. <SensorBinder type="gravity" rate="60">
  43. <Variable name="gravity_x" index="0" />
  44. <Variable name="gravity_y" index="1" />
  45. <Variable name="gravity_z" index="2" />
  46. </SensorBinder>
  47. <SensorBinder type="linear_acceleration">
  48. <Variable name="linear_acceleration_x" index="0" />
  49. <Variable name="linear_acceleration_y" index="1" />
  50. <Variable name="linear_acceleration_z" index="2" />
  51. </SensorBinder>
  52. <SensorBinder type="linear_acceleration" rate="2">
  53. <Variable name="va_x" index="0" />
  54. <Variable name="va_y" index="1" />
  55. <Variable name="va_z" index="2" />
  56. </SensorBinder>
  57. </VariableBinders>
  58. <!-- 公交卡-->
  59. <Group visibility="#nfc" >
  60. <Var name="shuaidong_judge" expression="#linear_acceleration_x" threshold="8">
  61. <Trigger>
  62. <VariableCommand name="shuaidong_num" expression="#shuaidong_num+1" />
  63. </Trigger>
  64. </Var>
  65. <Var name="shuaidong_num_judge" expression="#shuaidong_num" threshold="3">
  66. <Trigger>
  67. <IntentCommand action="com.miui.intent.action.DOUBLE_CLICK" package="com.miui.tsmclient">
  68. <Extra name="event_source" type="string" expression="'key_volume_down'" />
  69. </IntentCommand>
  70. </Trigger>
  71. </Var>
  72. </Group>
  73. </Lockscreen>
复制代码
1.删除<!--和-->之间内容包含<!---->
2.每行中数组降序
如<Text x="10" y="90" size="35" color="#ffffff" textExp="'cbl_ani: '+#cbl_ani"/>变为<Text textExp="'cbl_ani: '+#cbl_ani"  color="#ffffff" size="35" y="90" x="10"/>
如<Button x="0" y="0" w="#screen_width" h="#screen_height"/>变为<Button h="#screen_height" w="#screen_width "y="0" x="0"/>
3.去除段前段后空行 去除换行符 使其变成一行

本帖最后由 WHY 于 2019-5-14 13:46 编辑

test.ps1
  1. $str = [IO.File]::ReadAllText('a.txt', [Text.Encoding]::Default);
  2. $str = $str -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';
  3. $str = [regex]::Replace($str, '(?<=<[^<>\s]+)\s+[^<>]+"(?=\s*/?>)', {param($m); [Collections.ArrayList]$a=$m.Value -split '(?<=="[^"]*")';$a.Reverse();$a -join ''});
  4. [IO.File]::WriteAllText('b.txt', $str, [Text.Encoding]::UTF8);
复制代码
1

评分人数

    • smss: 就服你技术 + 1

TOP

回复 2# WHY 我可以知道你的联系方式吗?你已经帮助我很多次了。

TOP

回复 3# smss


    好,站内短信发给你了。

TOP

本帖最后由 smss 于 2019-5-16 13:39 编辑

回复 4# WHY
我把这个保存为好 用BAT调用
  1. @echo off
  2. powershell.exe -command "&{%~dp0test.ps1}"
复制代码
除了上边这种,可以类似以下这样写吗
  1. PowerShell "[Collections.ArrayList]$arr=[IO.File]::ReadAllLines('1.txt') -replace '^20|(?<!\d\d)\s';$arr.Reverse();sc 2.txt -Value $arr"
复制代码

TOP

返回列表