Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для madmasles

Ветеран


Сообщения: 812
Благодарности: 353

Профиль | Отправить PM | Цитировать


Cem,
Можно так попробовать сделать:
Код: Выделить весь код
Local $sTxt, $aSearch[3] = ['Собака', 'Кот', 'Черепаха'], $sImageFile, $sVideoFile

$sTxt = FileRead(@ScriptDir & '\tst.txt')

For $i = 0 To 2
    If Not StringInStr($sTxt, $aSearch[$i], 1) Then
        If Not StringInStr($sTxt, StringLower($aSearch[$i]), 1) Then
            ConsoleWrite('No word "' & $aSearch[$i] & '" in text' & @LF)
            ContinueLoop
        EndIf
    EndIf
    $sImageFile = StringRegExpReplace($sTxt, '(?ims).*^([a-z].*?\\' & $aSearch[$i] & '\.j.*?)$.*', '$1')
    If @extended <> 1 Then
        $sImageFile = StringRegExpReplace($sTxt, '(?ims).*^([a-z].*?\\' & StringLower($aSearch[$i]) & '\.j.*?)$.*', '$1')
        If @extended <> 1 Then
            ConsoleWrite('Can not search image file for word "' & $aSearch[$i] & '" in text' & @LF)
            ContinueLoop
        EndIf
    EndIf
    $sVideoFile = StringRegExpReplace($sTxt, '(?ims).*^([a-z].*?\\' & $aSearch[$i] & '\.m.*?)$.*', '$1')
    If @extended <> 1 Then
        $sVideoFile = StringRegExpReplace($sTxt, '(?ims).*^([a-z].*?\\' & StringLower($aSearch[$i]) & '\.m.*?)$.*', '$1')
        If @extended <> 1 Then
            ConsoleWrite('Can not search video file for word "' & $aSearch[$i] & '" in text' & @LF)
            ContinueLoop
        EndIf
    EndIf
    ConsoleWrite('image file for word "' & $aSearch[$i] & '": ' & $sImageFile & @LF)
    ConsoleWrite('video file for word "' & $aSearch[$i] & '": ' & $sVideoFile & @LF)
    ConsoleWrite('---' & @LF)
Next
tst.txt:
Код: Выделить весь код
Собака
D:\Image\Собака.jpeg
D:\Video\собака.mpeg

Кот
D:\Image\кот.jpeg
D:\Video\Кот.mpeg

черепаха
D:\Image\черепаха.jpeg
D:\Video\черепаха.mpeg

Последний раз редактировалось madmasles, 25-02-2014 в 11:07.

Это сообщение посчитали полезным следующие участники:

Отправлено: 10:51, 25-02-2014 | #5