本帖最后由 happy886rr 于 2017-7-25 12:43 编辑
用法:存为bat跟test.txt放一起。
JS混编- 1>1/* :
- @echo off&cls&cscript -nologo -e:jscript "%~f0" test.txt&pause&exit
- */
-
- var fso=new ActiveXObject('Scripting.FileSystemObject'), fp=fso.OpenTextFile(WScript.Arguments(0), 1);
- while(! fp.AtEndOfStream)
- {
- WScript.echo((fp.ReadLine()).replace(/(\d+)(\s.*)/, '第$1章$2'));
- }
复制代码 .
.
Csharp- /*************************************************************************
- @ECHO OFF&CLS&TITLE MINI CSHARP COMPILER BY HAPPY
- for /f "delims=" %%a in ('dir /a-d /b /s "%systemroot%\Microsoft.NET\Framework\csc.exe"') do (
- "%%~a" /out:a.exe "%~f0" && a.exe
- pause&exit/b
- )
- )
- set/p=You needs Microsoft.NET!&exit/b
- **************************************************************************/
- using System;
- using System.IO;
- using System.Text;
- using System.Text.RegularExpressions;
-
- namespace FileIOApplication
- {
- class Program
- {
- static void Main(string[] args)
- {
- FileStream inFp = new FileStream("test.txt", FileMode.Open, FileAccess.Read);
- FileStream outFp = new FileStream("test2.txt", FileMode.Create, FileAccess.Write);
-
- byte[] inFpBinary = new byte[inFp.Length];
- inFp.Read(inFpBinary, 0, (int)inFp.Length);
- inFp.Close();
-
- string inTextString = System.Text.Encoding.UTF8.GetString(inFpBinary);
- string outTextString = Regex.Replace(inTextString, @"(\d+)(\s.*)", @"第$1章$2");
-
- byte[] outFpBinary = System.Text.Encoding.Default.GetBytes(outTextString);
- outFp.Write(outFpBinary, 0, (int)outFpBinary.Length);
- outFp.Close();
- }
- }
- }
复制代码
|