>>272 //ASCIIコード0x21(!)から0x7E(~)以外が含まれてたらtrue //初めにパターンを作っておく。初めから展開しておいて直接関数内に置いたほうがスマートだけど var p = "[^"; for (var i = 0x21; i < 0x7f; i++) p += "\\x" + i.toString(16); p += "]"; //関数本体 function CheckExceptASCII(checking) { return (checking.match(p) != null); }
//VBSバージョン。やってることは同じ。 Dim pattern, i pattern = "[^" For i = 33 To 126 pattern = pattern & "\x" & Hex(i) Next pattern = pattern & "]"
//vbsだとオブジェクト作らないと正規表現使えないのか……。 Function CheckExceptASCII(checking) Dim regex Set regex = New RegExp regex.Pattern = pattern CheckExceptASCII = regex.Test(checking) End Function
Dim reg, matches, i, text 'textにファイルから文字列読込 Set reg = new RegExp reg.Pattern = "<tr>((?:.*\n)+?.*)</tr>" reg.IgnoreCase = True reg.Global = True Set matches = reg.Execute(text) For Each i In matches WScript.Echo(i.SubMatches(0)) Next
>>512 dim fso, file, ts, regEx, ret, T, S set fso = CreatObject("Scripting.FileSystemObject") set file = fso.GetFile("C:\2ch.txt") set ts = file.OpenAsTextStream(1) set regEx = New RegExp regEx.IgnoreCase = false regEx.Pattern = "2ch" T = "" S = "" do while ts.AtEndOfStream <> true S = ts.ReadLine ret = regEx.Test(S) if ret then T = T & S & vbCRLF end if loop ts.close
set file = fso.GetFile("C:\2ch_new.txt") set ts = file.OpenAsTextStream(2) ts.Write(T) ts.close
>>176 Option Explicit Dim objArgs , objFS , objFile Set objArgs = WScript.Arguments Set objFS = CreateObject("Scripting.FileSystemObject") Set objFile = objFS.GetFile(objArgs(0)) '検索置換関数 Function RegReplace(targetstring, pattern, replacestring) Dim regEx dim retVal Set regEx = New RegExp regEx.Pattern = pattern regEx.IgnoreCase = True regEx.Global = true retVal = regEx.Test(targetstring) If retVal then RegReplace = regEx.Replace(targetstring , replacestring) End If End Function '↓この行を増やせば何種類でも対応↓ objFile.Name = RegReplace(objFile.Name , "\.hoge$" , ".hage") objFile.Name = RegReplace(objFile.Name , "\.hage$" , ".hige")
188 名前:sage 185 投稿日:04/12/17 23:52:07 ID:E3RuCigl
Option Explicit Dim objArgs , objFS , objFile Set objArgs = WScript.Arguments Set objFS = CreateObject("Scripting.FileSystemObject") Set objFile = objFS.GetFile(objArgs(0)) '検索置換関数、検索結果のブール値を返す。 Function RegReplace(targetstring, pattern, replacestring) Dim regEx dim retVal Set regEx = New RegExp regEx.Pattern = pattern regEx.IgnoreCase = True regEx.Global = true retVal = regEx.Test(targetstring) If retVal then RegReplace = regEx.Replace(targetstring , replacestring) Else RegReplace = targetstring End If End Function '↓この行を増やせば何種類でも対応↓ If objFile.Name <> RegReplace(objFile.Name , "\.hoge$" , ".hage") Then objFile.Name = RegReplace(objFile.Name , "\.hoge$" , ".hage") Wscript.Quit ElseIf objFile.Name <> RegReplace(objFile.Name , "\.hage$" , ".hige") Then objFile.Name = RegReplace(objFile.Name , "\.hage$" , ".hige") Wscript.Quit End If '多分完成。
Function LastIsZenkaku(text) LastIsZenkaku = IsZenkaku(text, Len(text)) End Function Function IsZenkaku(char, index) Dim regex Set regex = New RegExp regex.Pattern = "[\u3000-\u9FFF\uF900-\uFDFF\uFF10-\uFF19]" IsZenkaku = regex.Test(Mid(text, index)) End Function
Dim WshShell, oExec, regEx Set WshShell = WScript.CreateObject("WScript.Shell") Set objIE = CreateObject("InternetExplorer.Application") Set regEx = New RegExp
Function Ping(vIPAddress) For i = 0 To 10 Set oExec = WshShell.Exec("ping -n 1 " & vIPAddress) Do While oExec.Status <> 1: WScript.Sleep 100: Loop res = oExec.StdOut.ReadAll regEx.Pattern = "Reply .* time.*" regEx.IgnoreCase = True Set Matches = regEx.Execute(res) tmpMsg = tmpMsg & Matches(0).Value
Next WScript.Echo tmpMsg End Function clip = objIE.Document.ParentWindow.ClipboardData.GetData("Text") Ping(clip)
//半角 ==> 全角 変換 var O_Dic = {} , Re_Hankana = new RegExp(); sub_initialize(O_Dic, Re_Hankana);
var s = sub_hanToZen("アイスでゴザイマス"); WScript.Echo(s.split("").join("\n"));
s = sub_hanToZen("パソコン検定"); //パは未定義なのでハだけ変換 WScript.Echo(s.split("").join("\n"));
function sub_hanToZen(s){ return s.replace( Re_Hankana , sub_replaceFunc ); } function sub_initialize(dic, reHan){ var s_zen1 = "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン"; var s_han1 = "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン";
var s_zen2 = "ガギグゲゴザジズゼゾ"; var s_han2 = "ガギグゲゴザジズゼゾ";
var a_zen2 = s_zen2.split(""); var a_han2 = s_han2.match(/../g);
var a_zen = s_zen1.split("").concat( a_zen2 ); var a_han = s_han1.split("").concat( a_han2 );
Set HTTP = WScript.CreateObject("Microsoft.XMLHTTP") Set Stream = WScript.CreateObject("Adodb.Stream") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set Shell = WScript.CreateObject("Shell.Application")
Set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = True
var urlList = new Array(); expandUrl(urlList, "www.hogehoge.com/[01-03]/[03-05].jpg"); WScript.echo(urlList);
function expandUrl(urlList, url) { var re = new RegExp("[[]([0-9]+)-([0-9]+)[]]"); var arr = re.exec(url);
if (arr == null) { urlList.push(url); return; }
var beginStr = RegExp.$1; //エイリアス var begin = parseInt(RegExp.$1); var end = parseInt(RegExp.$2); var leftContext = new String(RegExp.leftContext); var rightContext = new String(RegExp.rightContext);
Set WshShell = WScript.CreateObject("WScript.Shell") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = False
For Each sArg In WScript.Arguments If Fs.FileExists(sArg) And LCase(Fs.GetExtensionName(sArg))="lnk" Then Set oShortCut=WshShell.CreateShortcut(sArg) With oShortCut sTargetPath=.TargetPath If LCase(Fs.GetFileName(sTargetPath)) = "cmd.exe" Then regEx.Pattern="\/([RHANBL]\S*)" Set Matches =regEx.Execute (.Arguments) For Each Match In Matches sPriorityAccessKey = Left(Match.SubMatches(0),1) Next regEx.Pattern="cmd.*\s\/[RHANBL]\S*\s+(.*)" Set Matches =regEx.Execute (.Arguments) For Each Match In Matches sProgArg =Match.SubMatches(0) Next Else sPriorityAccessKey = "N" sProgArg = RTrim(sTargetPath & " " & .Arguments) End If
var objFs = new ActiveXObject("Scripting.FileSystemObject"); objFs.CreateTextFile(queueFilePath); var file = objFs.GetFile(queueFilePath); var fout = file.OpenAsTextStream(ForWriting, TristateUseDefault);
var urlList = new Array(); expandUrl(urlList, url);
while (urlList.length > 0) fout.Write(makeIrvineQueue(urlList.pop()));
fout.Close(); }
function makeIrvineQueue(url) { var re = new RegExp("([^/]+)/([^/]+)$"); var arr = re.exec(url);
function expandUrl(urlList, url) { var re = new RegExp("[[]([0-9]+)-([0-9]+)[]]"); var arr = re.exec(url);
if (arr == null) { urlList.push(url); return; }
var beginStr = RegExp.$1; //エイリアス var begin = parseInt(RegExp.$1); var end = parseInt(RegExp.$2); var leftContext = new String(RegExp.leftContext); var rightContext = new String(RegExp.rightContext);
for (var i = begin; i <= end; i++) { var si = i.toString(); if (fillMode) while (si.length < fillSize) si = "0" + si;
var expUrl = leftContext + si + rightContext; expandUrl(urlList, expUrl); } }
410 名前:11 sage 投稿日:02/02/06 18:53
Dim iRes Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") Set dicIdx = WScript.CreateObject("Scripting.Dictionary") Set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = True
If Not Fs.FileExists("kage.exe") Then MsgBox "かちゅ〜しゃのあるフォルダにおいてください。それとkage導入して。" WScript.Quit End If
If Not Fs.FileExists("kakikomi.txt") THen MsgBox "ROMはお断りだゴルァ" WScript.Quit End If
If Not Fs.FolderExists("log") THen MsgBox "ログがない。" WScript.Quit End If
Set tsKakikomi=Fs.OpenTextFile("kakikomi.txt") sKakikomi=tsKakikomi.ReadAll tsKakikomi.Close
If Not Fs.FolderExists("log\local") Then Fs.CreateFolder "log\local" End If
If Not Fs.FolderExists("log\local\mine") Then Fs.CreateFolder "log\local\mine" End If
Dim RegEx,RegEx2,Fs Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set RegEx=New RegExp Set RegEx2=New RegExp RegEx.IgnoreCase=True RegEx.Global=True
For Each sArg In WScript.Arguments If Fs.FolderExists(sArg) Then For Each oFile In Fs.GetFolder(sArg).Files Call RenameHTMLFile(oFile) Next ElseIf Fs.FileExists(sArg) Then Call RenameHTMLFile(Fs.GetFile(sArg)) End If Next
MsgBox "終了"
522 名前:うっしゅ君14世 sage 投稿日:02/02/25 01:14
Dim WshShell, oExec, regEx Set WshShell = CreateObject("WScript.Shell") Set regEx = New RegExp
For i = 150 To 190 Set oExec = WshShell.Exec("ping -n 1 61.116.87." & i) Do While oExec.Status <> 1: WScript.Sleep 100: Loop res = oExec.StdOut.ReadAll regEx.Pattern = "Reply .* time.*" regEx.IgnoreCase = True Set Matches = regEx.Execute(res)
If Matches.Count > 0 Then WScript.Echo Matches(0).Value End If Next
>>838 //.html をこのスクリプトに Drop //置換して上書きします。"逆の操作" にすると元に戻します //(注) 元に戻らない場合もあります
var w=WSH; if(0==w.Arguments.length) w.echo('引数がありません'),w.quit(); var objFs=new ActiveXObject('Scripting.FileSystemObject'); var str_arg=w.Arguments.Item(0); if(!objFs.FileExists(str_arg) || 'html'!=objFs.GetExtensionName(str_arg).toLowerCase()) w.echo('引数は無効です'),w.quit();
var obj_text=objFs.OpenTextFile(str_arg,1); //読込み open var str_text=obj_text.ReadAll(); obj_text.Close();
str_text=str_text.replace(/[^\n](<dt>)/ig,'\r\n$1'); //<dt>の前にCRLFを付加する //str_text=str_text.replace(/\r\n(<dt>)/ig,'$1'); //逆の操作 obj_text=objFs.OpenTextFile(str_arg,2); //書込み open obj_text.Write(str_text); obj_text.Close();
var w=WScript; if(0==w.Arguments.length) w.echo('引数がありません'),w.quit(); var objFs=new ActiveXObject('Scripting.FileSystemObject'); var objWs=new ActiveXObject('WScript.Shell');
var str_arg=sub_getTarget(w.Arguments.Item(0)); if(!objFs.FileExists(str_arg) || !/\.html$/i.test(str_arg)) w.echo('引数は無効です'),w.quit();
var obj_text=objFs.OpenTextFile(str_arg,1); //読込み open var str_text=obj_text.ReadAll(); obj_text.Close();