DOWN LOAD BBS

HOME HELP 新規作成 新着記事 ツリー表示 スレッド表示 トピック表示 ファイル一覧 検索 過去ログ

■155 / 親階層)  ハイパーリンク
□投稿者/ hidetake -(2003/03/18(Tue) 00:36:50)
    桐でやる手ももちろんだけれど,正規表現を使えれば
    こんな風に出来るというサンプルの意味も含めて・・・

    取り敢えず,今時の Windows であれば大体において
    使えるであろう WSH のうち VBS でのスクリプト例!

    ex. httplink.vbs infile outfile

    -------------------------------------------------------------------------------
    Dim Arg
    Set Arg = WScript.Arguments
    If Arg.Count < 2 Then
    WScript.Quit
    End If

    Dim Src, Dst
    Src=Arg(0)
    Dst=Arg(1)

    Dim Fs
    Set Fs = Wscript.CreateObject("Scripting.FileSystemObject")
    If Not Fs.FileExists(Src) Then
    WScript.Echo "ファイルがありません!"
    Set Fs = Nothing
    Set Arg = Nothing
    WScript.Quit
    End If
    If Fs.FileExists(dst) = True Then
    Fs.DeleteFile dst,True
    End If

    Set sFile = Fs.OpenTextFile(Src)
    Set dFile = FS.CreateTextFile(Dst)

    Dim Line
    Set objRE = New RegExp
    objRE.IgnoreCase = True
    objRE.Global = True
    objRE.Pattern = "(((s?https?|ftp)://|mailto:)[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+)"

    Do Until sFile.AtEndOfStream
    Line = sFile.ReadLine
    If Line = Chr(&h1A) Then
    Exit Do
    End If
    If objRE.Test(Line) = True Then
    Line = objRE.Replace(Line,"" + "$1" + "")
    End If
    dFile.WriteLine(Line)
    Loop

    sFile.Close
    dFile.Close
    Set sFile = Nothing
    Set dFile = Nothing
    Set Arg = Nothing
    Set Fs = Nothing
    WScript.Quit
    -------------------------------------------------------------------------------


[メール受信/OFF] 削除キー/

→Re[1]: ハイパーリンク /hidetake
 
前の記事(元になった記事) 次の記事(この記事の返信)
上記関連ツリー

Nomal ハイパーリンク / hidetake (03/03/18(Tue) 00:36) #155 ←Now
Nomal Re[1]: ハイパーリンク / hidetake (03/03/18(Tue) 00:37) #156
  └Nomal Re[2]: ハイパーリンク / hidetake (03/03/18(Tue) 00:39) #157 解決済み!

All 上記ツリーを一括表示 / 上記ツリーをトピック表示
 
上記の記事へ返信

Mode/  Pass/

HOME HELP 新規作成 新着記事 ツリー表示 スレッド表示 トピック表示 ファイル一覧 検索 過去ログ

- Child Tree -
- Antispam Version -