我正在编写一个脚本,该脚本需要在文本文件中查找数值或数字并将其替换为键盘输入。
我已经在互联网上搜索过,只是找不到正确的方法。
文本文件包含以下内容:
import { NgxfUploaderModule } from 'ngxf-uploader'; // import statement
describe('RepairFormComponent', () => {
let fixture;
let component: RepairFormComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
ReactiveFormsModule,
FormsModule,
NgxfUploaderModule
],
declarations: [
RepairFormComponent,
FileUploaderComponent,
],
providers: [
NgxfUploaderService,
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RepairFormComponent);
component = fixture.componentInstance;
});
it('should create the repair form', () => expect(component).toBeDefined());
});
我需要将“ 80cl1”部分更改为新值,例如:80cl1更改为84cl3
C:\Progra~1\Java\userapp\fundays\jv10_80cl1\test
因此,脚本需要找到这些值并通过键盘输入对其进行更改。
答案 0 :(得分:0)
类似的事情应该会有所帮助。您可以将 // TOUCH DOWN
@IBAction func SliderTouchDown(_ sender: UISlider) {
playerItem?.pause()
}
//TOUCH UP INSIDE
@IBAction func SliderTouchUpInside(_ sender: UISlider) {
playerItem?.currentTime = TimeInterval(sliderProgressOutlet.value)
playerItem?.play()
}
更改为不提示,只给它一个值,这两种方法都会起作用:
set /p
如果您不想被吹捧,只需事先设置值即可:
@echo off
setlocal enabledelayedexpansion
set inputfile=install.txt
set /p "_strfind=Enter value to search?"
set /p "_strinsert=Replacement value?"
for /f "tokens=*" %%a in ('type "%inputfile%" ^| find /v /n "" ^& break ^> "%inputfile%"') do (
set "str=%%a"
set "str=!str:%_strfind%=%_strinsert%!"
set "str=!str:*]=!"
>>%inputfile% echo(!str!
)
如果您的文件可能包含@echo off
setlocal enabledelayedexpansion
set inputfile=install.txt
set "_strfind=80cl1"
set "_strinsert=84cl3"
for /f "tokens=*" %%a in ('type "%inputfile%" ^| find /v /n "" ^& break ^> "%inputfile%"') do (
set "str=%%a"
set "str=!str:%_strfind%=%_strinsert%!"
set "str=!str:*]=!"
>>%inputfile% echo(!str!
)
,它将不会将它们复制到文件中,则只需使用以下方法:
!
根据您的评论进行编辑:
@echo off
set "inputfile=ip.txt"
set /p "_strfind=string to replace?"
set /p "_strinsert=replacement string?"
for /f "tokens=*" %%a in ('type "%inputfile%" ^| find /v /n "" ^& break ^> "%inputfile%"') do (
set "str=%%a"
setlocal enabledelayedexpansion
set "str=!str:%_strfind%=%_strinsert%!"
call set "str=%%str:*]=%%"
>>%inputfile% echo(!str!
endlocal
)