Juri Posted May 12, 2010 Share Posted May 12, 2010 (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 May 12, 2010 by Juri Link to comment Share on other sites More sharing options...
omikron48 Posted May 12, 2010 Share Posted May 12, 2010 You can use StringReplace to eliminate all occurances of a certain substring. Global $string = "She sells seashells by the sea shore." Global $substring = "she" StringReplace($string, $subtring, "") Link to comment Share on other sites More sharing options...
Juri Posted May 12, 2010 Author Share Posted May 12, 2010 (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 May 12, 2010 by Juri Link to comment Share on other sites More sharing options...
omikron48 Posted May 12, 2010 Share Posted May 12, 2010 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)? Link to comment Share on other sites More sharing options...
Juri Posted May 12, 2010 Author Share Posted May 12, 2010 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. Link to comment Share on other sites More sharing options...
omikron48 Posted May 12, 2010 Share Posted May 12, 2010 Maybe use StripWS then StringLen to check if a line is empty then skip it? Link to comment Share on other sites More sharing options...
Juri Posted May 12, 2010 Author Share Posted May 12, 2010 (edited) So, i must read all line and check it ? Hmmm i check this method ;P But i want easier method Edited May 12, 2010 by Juri Link to comment Share on other sites More sharing options...
omikron48 Posted May 12, 2010 Share Posted May 12, 2010 (edited) That's one way to do it. Dunno if there's a better way though, but I'd wager that there probably is. Edited May 12, 2010 by omikron48 Link to comment Share on other sites More sharing options...
Juri Posted May 12, 2010 Author Share Posted May 12, 2010 Yea 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now