标题: [已解决]20元 bat或Powershell处理文本内容使其倒序排列 [打印本页]
作者: smss 时间: 2019-5-13 13:34 标题: [已解决]20元 bat或Powershell处理文本内容使其倒序排列
具体报酬:20元人民币
支付方式:支付宝,微信转账
联系方式:QQ296578353
有效期限:问题解决之前。WHY请联系一下我可以吗?转点小钱略表感谢。已经帮助我很多次了,而且每次给出的答案都是切实可行的。
情景再现自己写好的代码 被人抄袭套用 可气的是对方还在代码前加上“原创代码,抄袭举报” 真是此地无银三百两掩耳盗铃的小人
为了保护自身知识产权,需要一个把写好的代码中数组位置置换 去除写代码时的思路备注 去除换行符号(后边再用工具加密)
需要处理以下类似文本- <?xml version="1.0" encoding="UTF-8"?>
- <Lockscreen screenWidth="1080" frameRate="45" displayDesktop="true" scale="1*#scalescreen" pivotX="#screen_width/2" pivotY="#screen_height/2" alpha="255*#homescreen_action">
- <!-- Start-2019.5.12 =x=2019.5.12 -->
- <Button x="0" y="0" w="#screen_width" h="#screen_height" />
- <ExternalCommands>
- <Trigger action="resume">
- <VariableCommand name="ts" expression="0" />
- <VariableCommand name="Sidebar_v" expression="0" />
- <VariableCommand name="wallpaper_mask" expression="1" />
- <VariableCommand name="slider_xy_flag" expression="0" />
- <VariableCommand name="unlocker_flag" expression="0" />
- <VariableCommand name="unlocked" expression="0" />
- <AnimationCommand target="timemove" command="play(500,1000)" delay="0" condition="eq(#timemove,0)*#blackbg" />
- <AnimationCommand target="timemove2" command="play(500,1400)" delay="0" condition="eq(#timemove2,0)*#blackbg" />
- <AnimationCommand target="timemove3" command="play(500,1800)" delay="0" condition="eq(#timemove3,0)*#blackbg" />
- <AnimationCommand target="timemove" command="play(1000,0)" delay="0" condition="eq(#timemove,0)*not(#blackbg)" />
- <AnimationCommand target="timemove2" command="play(1400,0)" delay="0" condition="eq(#timemove2,0)*not(#blackbg)" />
- <AnimationCommand target="timemove3" command="play(1800,0)" delay="0" condition="eq(#timemove3,0)*not(#blackbg)" />
- <AnimationCommand target="appmove" command="play(800,0)" delay="0" condition="eq(#appmove,0)*not(#blackbg)" />
- <AnimationCommand target="appalpha" command="play(0)" delay="0" condition="eq(#appalpha,0)*not(#blackbg)" />
- <AnimationCommand target="bzmove" command="play" />
- </Trigger>
- <Trigger action="pause">
- <VariableCommand name="Sidebar_v" expression="0" />
- <VariableCommand name="suiji_bg" expression="ifelse(not(#Img_ID),round(rand(0)*7+1),#Img_ID)" />
- <AnimationCommand target="scale_charge" command="play(200,0)" condition="eq(#charge,1)"/>
- <AnimationCommand target="chargealpha" command="play(200,0)" condition="eq(#charge,1)"/>
- <AnimationCommand target="bgalpha" command="play(1800,0)" condition="eq(#blackbg,1)" />
- </Trigger>
- </ExternalCommands>
-
- <VariableBinders>
- <ContentProviderBinder name="data" uri="content://keyguard.notification/notifications" columns="icon,title,content,time,info,subtext,key" countName="hasnotifications">
- <Variable name="notification_icon" type="blob.bitmap" column="icon" row="0" />
- <Variable name="notification_title" type="string" column="title" row="0" />
- <Variable name="notification_content" type="string" column="content" row="0" />
- <Variable name="notification_time" type="string" column="time" row="0" />
- <Variable name="notification_info" type="string" column="info" row="0" />
- <Variable name="notification_subtext" type="string" column="subtext" row="0" />
- <Variable name="notification_key" type="int" column="key" row="0" />
- <List name="notification_list" />
- </ContentProviderBinder>
- <SensorBinder type="gravity" rate="60">
- <Variable name="gravity_x" index="0" />
- <Variable name="gravity_y" index="1" />
- <Variable name="gravity_z" index="2" />
- </SensorBinder>
- <SensorBinder type="linear_acceleration">
- <Variable name="linear_acceleration_x" index="0" />
- <Variable name="linear_acceleration_y" index="1" />
- <Variable name="linear_acceleration_z" index="2" />
- </SensorBinder>
- <SensorBinder type="linear_acceleration" rate="2">
- <Variable name="va_x" index="0" />
- <Variable name="va_y" index="1" />
- <Variable name="va_z" index="2" />
- </SensorBinder>
- </VariableBinders>
-
- <!-- 公交卡-->
- <Group visibility="#nfc" >
- <Var name="shuaidong_judge" expression="#linear_acceleration_x" threshold="8">
- <Trigger>
- <VariableCommand name="shuaidong_num" expression="#shuaidong_num+1" />
- </Trigger>
- </Var>
- <Var name="shuaidong_num_judge" expression="#shuaidong_num" threshold="3">
- <Trigger>
- <IntentCommand action="com.miui.intent.action.DOUBLE_CLICK" package="com.miui.tsmclient">
- <Extra name="event_source" type="string" expression="'key_volume_down'" />
- </IntentCommand>
- </Trigger>
- </Var>
- </Group>
- </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 11:49
本帖最后由 WHY 于 2019-5-21 09:39 编辑
test.ps1- $str = [IO.File]::ReadAllText('a.txt', [Text.Encoding]::Default);
- $str = $str -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';
- $str = [regex]::Replace($str, '(?<=<[^<>\s]+)\s+[^<>]+"(?=\s*/?>)', {param($m); [Collections.ArrayList]$a=$m.Value -split '(?<=="[^"]*")';$a.Reverse();$a -join ''});
- [IO.File]::WriteAllText('b.txt', $str, [Text.Encoding]::UTF8);
复制代码
如果要保存为Test.BAT
(1) 对ps脚本块而言,双引号用反斜杠转义;
(2) 对bat脚本而言,暴露在 "双引号对" 之外的特殊字符用^转义。- @echo off
- PowerShell "$s = [IO.File]::ReadAllText('a.txt', [Text.Encoding]::Default) -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';$s = [regex]::Replace($s, '(?<=<[^<>\s]+)\s+[^<>]+\"(?=\s*/?^>)',{param($m);[Collections.ArrayList]$a=$m.Value -split '(?^<==\"[^\"]*\")';$a.Reverse();$a -join ''});sc b.txt -Value $s -Enc UTF8"
- pause
复制代码
作者: smss 时间: 2019-5-14 13:37
回复 2# WHY 我可以知道你的联系方式吗?你已经帮助我很多次了。
作者: WHY 时间: 2019-5-14 21:19
回复 3# smss
好,站内短信发给你了。
作者: smss 时间: 2019-5-15 20:51
本帖最后由 smss 于 2019-5-20 21:16 编辑
回复 4# WHY
我把这个保存为好 用BAT调用- @echo off
- powershell.exe -command "&{%~dp0test.ps1}"
复制代码
除了上边这种,可以类似以下这样写吗- PowerShell "[Collections.ArrayList]$arr=[IO.File]::ReadAllLines('1.txt') -replace '^20|(?<!\d\d)\s';$arr.Reverse();sc 2.txt -Value $arr"
复制代码
- PowerShell "$str=[IO.File]::ReadAllText('manifest.xml', [Text.Encoding]::Default);$str=$str -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';[IO.File]::WriteAllText('manifest1.xml', $str, [Text.Encoding]::UTF8)"
复制代码
只加成功半句 难受- PowerShell "$str=[IO.File]::ReadAllText('manifest.xml', [Text.Encoding]::Default);$str=$str -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';$str=[regex]::Replace($str, '(?<=<[^<>\s]+)\s+[^<>]+"(?=\s*/?>)', {param($m); [Collections.ArrayList]$a=$m.Value -split '(?<=="[^"]*")';$a.Reverse();$a -join ''});[IO.File]::WriteAllText('manifest1.xml', $str, [Text.Encoding]::UTF8)"
- 最后一句不知道错在哪
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |