Jump to content

Recommended Posts

Posted (edited)

Hello. I need help. I want to remove "<br>" form this text:

Obrońca zwyciężył
Szczęście (z punktu widzenia agresora)
Pech ,
,,,
,Szczęście ,17.0%
Morale: 100%

Agresor:,Jurigag
Pochodzenie:,Myrthana Vengard (671|541) K56
,,,,,,,,,,,,
Ilość: ,0,0,0,0,5,0,0,0,0,0,0,0
Straty: ,0,0,0,0,0,0,0,0,0,0,0,0

Obrońca:,klk*
cel:,klk* (673|537) K56
,,,,,,,,,,,,
Ilość: ,3,0,0,0,0,0,0,0,0,0,0,0
Straty: ,0,0,0,0,0,0,0,0,0,0,0,0

Szpiegostwo
Wyszpiegowane surowce:,nie ma
,Ratusz (Stopień 10)
Koszary (Stopień 2)
Kuźnia (Stopień 5)
Plac (Stopień 1)
Piedestał (Stopień 1)
Rynek (Stopień 1)
Tartak (Stopień 8)
Cegielnia (Stopień 6)
Huta żelaza (Stopień 5)
Zagroda (Stopień 4)
Spichlerz (Stopień 7)
Schowek (Stopień 1)
Mur obronny (Stopień 1)

I want to convert this text to:

Obrońca zwyciężył
Szczęście (z punktu widzenia agresora)
Pech ,
,,,
,Szczęście ,17.0%
Morale: 100%
Agresor:,Jurigag
Pochodzenie:,Myrthana Vengard (671|541) K56
,,,,,,,,,,,,
Ilość: ,0,0,0,0,5,0,0,0,0,0,0,0
Straty: ,0,0,0,0,0,0,0,0,0,0,0,0
Obrońca:,klk*
cel:,klk* (673|537) K56
,,,,,,,,,,,,
Ilość: ,3,0,0,0,0,0,0,0,0,0,0,0
Straty: ,0,0,0,0,0,0,0,0,0,0,0,0
Szpiegostwo
Wyszpiegowane surowce:,nie ma
,Ratusz (Stopień 10)
Koszary (Stopień 2)
Kuźnia (Stopień 5)
Plac (Stopień 1)
Piedestał (Stopień 1)
Rynek (Stopień 1)
Tartak (Stopień 8)
Cegielnia (Stopień 6)
Huta żelaza (Stopień 5)
Zagroda (Stopień 4)
Spichlerz (Stopień 7)
Schowek (Stopień 1)
Mur obronny (Stopień 1)

And, solution this problem must working on more "<br>". Possible?

Edited by Juri
Posted (edited)

I know this, but i cant replace "breaking the line". I need this to my "analysator" to working on all web viewers ;/

Or this function return number of line without breaking the line:

Func _LineNumsOfSearchStr($sFileName, $searchString, $bDeleteLine = False)
    Local $location, $aCurrentLineNum, $iCurrentLineNum, $sFile, $iOccur = 1, $sRes = ""
    If FileExists($sFileName) = 0 Then Return 1
    Do
        $sFile = FileRead($sFileName)
        $location = StringInStr($sFile, $searchString, 0, $iOccur) ; Find the $iOccur occurrence of the "substring"

        If $location > 0 Then
            $aCurrentLineNum = StringRegExp(StringRegExpReplace($sFile, "(?s)(.{" & $location & "})(.*)$", "\1"), "(?s)(\v+)", 3) ;Find line number
            $iCurrentLineNum = UBound($aCurrentLineNum) + 1 ; Line number

            ;ConsoleWrite("CharPos: " &  $location & "   Ln: " & $iCurrentLineNum & @CRLF)
            $sRes &= $iCurrentLineNum & "|"
            If $bDeleteLine Then
                _FileWriteToLine($sFileName, $iCurrentLineNum, "", 1) ; Remove found line from file.
            Else
                $iOccur += 1
            EndIf
        Else
            ExitLoop
        EndIf
        Sleep(10)
    Until 0
    ;ShellExecute($sFileName)
    Return StringSplit(StringTrimRight($sRes, 1), "|")
EndFunc   ;==>_LineNumsOfSearchStr

I search this function on forum. How to chagne this function to return number of line with breaking the line?

Edited by Juri
Posted

Well, first off, how to you get the text you want to process?

Do you get it as raw text including html tags (like when you view a webpage's source) or do you get it as already formatted text (like when you highlight a webpage and copy/paste the text into a text editor)?

Posted

I get this very simple, because application want to work in tray and only open anaylysed file and nothing get from server. I get copy text from Clipget() and stringregexp that text if i want.

Posted (edited)

So, i must read all line and check it ? Hmmm i check this method ;P But i want easier method :idea:

Edited by Juri
Posted

Yea :idea: I have easy method :)

#include <file.au3>

$file = FileOpen("bk.txt", 0) ; File with breaking line

While 1
    $line = FileReadLine($file)
    if StringLen($line)>0 Then ; Check this is not breaking line
        FileWrite("bk2.txt", $line & @CRLF) ; Save this to new file
    endif
    If @error = -1 Then ExitLoop
WEnd
FileClose($file)

Works perfectly for me :(

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...