Sign in to follow this  
Followers 0
Jammer

Problem with StringReplace

4 posts in this topic

Hi,

I have a BIG html file which was gotten by _IEDocReadHTML.

And there is one long line (this is the last small peace of it):

<a href="?newdid=100123422" class="active_vl">Town3</a></td><td class="right"><table class="dtbl" cellspacing="0" cellpadding="0">

Im doing:

$Line = StringReplace($Line, ' class="active_vl"', "")

If I do the replacement only for a Line everything is OK.

But if I use the repalcing function on the whole source of the document I get: 0 found expressions.

Also I may add that there is only one expression like this in the source.

Try it your self and you'll see.

Maby there is a problem when I need replacing the " chars, maby i should try \" or something like that?

The Whole HTML Document:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd"><html>
<head>
<title>Travian lt3</title>
<link rel=stylesheet type="text/css" href="new.css">
<link rel=stylesheet type="text/css" href="unx.css">
<script src="unx.js" type="text/javascript"></script>

<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body onload="start()"><div id="ltop1"><div id="ltop5"><a href="dorf1.php"><img style="filter:chroma();" id="n1" src="img/un/a/x.gif" title="GyvenvietÄs apžvalga"></a><a href="dorf2.php"><img id="n2" src="img/un/a/x.gif" title="GyvenvietÄs centras"></a><a href="karte.php"><img id="n3" src="img/un/a/x.gif" title="ŽemÄlapis"></a><a href="statistiken.php"><img id="n4" src="img/un/a/x.gif" title="Statistika"></a><img id="n5" src="img/un/l/m3.gif" usemap="#nb"><a href="plus.php"><img id="lplus1" src="img/lt/a/plus.gif" width="80" height="100" title="Pliuso meniu"></a></div></div><map name="nb"><area shape=rect coords="0,0,35,100" href="berichte.php" title="Ataskaitos"><area shape=rect coords="35,0,70,100" href="nachrichten.php" title="LaiÅ¡kai"></map><div id="lmidall"><div id="lmidlc"><div id="lleft">

<a href="http://www.travian.lt/"><img class="logo" src="img/lt/a/travian0.gif"></a><table id="navi_table" cellspacing="0" cellpadding="0">
<tr>
<td class="menu">
<a href="http://www.travian.lt/">Pradžia</a>
<a href="#" onclick="Popup(0,0); return false;">Žinynas</a>
<a href="spieler.php?uid=4373">Nustatymai</a><a href="logout.php">Atsijungti</a><br><br>
<a href="http://forum.travian.lt/" target="_blank">Forumas</a><a href="http://www.travian.lt/chat.php?chatname=lt3|" target="_blank">Pokalbiai</a><br><br><a href="plus.php?id=3">Travian <b><font color="#71D000">P</font><font color="#FF6F0F">l</font><font color="#71D000">i</font><font color="#FF6F0F">u</font><font color="#71D000">s</font><font color="#FF6F0F">a</font><font color="#71D000">s</font></b></a><a href="support.php">Palaikymas</a></td>
</tr>
</table></div><div id="lmid1"><div id="lmid2"><div class="dname"><h1>Kagor</h1></div>

<map name="rx"><area href="build.php?id=1" coords="101,33,28" shape="circle" title="Geležies kasykla lygis 10"><area href="build.php?id=2" coords="165,32,28" shape="circle" title="GrÅ«dų ferma lygis 10"><area href="build.php?id=3" coords="224,46,28" shape="circle" title="Medžių kirtavietÄ lygis 10"><area href="build.php?id=4" coords="46,63,28" shape="circle" title="Geležies kasykla lygis 10"><area href="build.php?id=5" coords="138,74,28" shape="circle" title="Molio karjeras lygis 10"><area href="build.php?id=6" coords="203,94,28" shape="circle" title="Molio karjeras lygis 10"><area href="build.php?id=7" coords="262,86,28" shape="circle" title="Geležies kasykla lygis 10"><area href="build.php?id=8" coords="31,117,28" shape="circle" title="GrÅ«dų ferma lygis 10"><area href="build.php?id=9" coords="83,110,28" shape="circle" title="GrÅ«dų ferma lygis 10"><area href="build.php?id=10" coords="214,142,28" shape="circle" title="Geležies kasykla lygis 10"><area href="build.php?id=11" coords="269,146,28" shape="circle" title="Geležies kasykla lygis 10"><area href="build.php?id=12" coords="42,171,28" shape="circle" title="GrÅ«dų ferma lygis 10"><area href="build.php?id=13" coords="93,164,28" shape="circle" title="GrÅ«dų ferma lygis 10"><area href="build.php?id=14" coords="160,184,28" shape="circle" title="Medžių kirtavietÄ lygis 10"><area href="build.php?id=15" coords="239,199,28" shape="circle" title="GrÅ«dų ferma lygis 10"><area href="build.php?id=16" coords="87,217,28" shape="circle" title="Molio karjeras lygis 10"><area href="build.php?id=17" coords="140,231,28" shape="circle" title="Medžių kirtavietÄ lygis 10"><area href="build.php?id=18" coords="190,232,28" shape="circle" title="Molio karjeras lygis 10"><area href="dorf2.php" coords="144,131,36" shape="circle" title="GyvenvietÄs centras"></map>

<div id="f2"><img src="img/un/g/s/s10.gif" class="rf1"><img src="img/un/g/s/s10.gif" class="rf2"><img src="img/un/g/s/s10.gif" class="rf3"><img src="img/un/g/s/s10.gif" class="rf4"><img src="img/un/g/s/s10.gif" class="rf5"><img src="img/un/g/s/s10.gif" class="rf6"><img src="img/un/g/s/s10.gif" class="rf7"><img src="img/un/g/s/s10.gif" class="rf8"><img src="img/un/g/s/s10.gif" class="rf9"><img src="img/un/g/s/s10.gif" class="rf10"><img src="img/un/g/s/s10.gif" class="rf11"><img src="img/un/g/s/s10.gif" class="rf12"><img src="img/un/g/s/s10.gif" class="rf13"><img src="img/un/g/s/s10.gif" class="rf14"><img src="img/un/g/s/s10.gif" class="rf15"><img src="img/un/g/s/s10.gif" class="rf16"><img src="img/un/g/s/s10.gif" class="rf17"><img src="img/un/g/s/s10.gif" class="rf18"></div>

<img id="resfeld" usemap="#rx" src="img/un/a/x.gif">
<div><div id="lplz1"></div><div id="ltbw1"></div><div id="lrpr">

<div class="f10 b">&nbsp;Gamyba:</div>

<table>
<tr>
<td><img class="res" src="img/un/r/1.gif"></td>
<td>Mediena:</td><td align="right"><b>750&nbsp;</b></td><td>per valandÄ</td>
</tr>
<tr>
<td><img class="res" src="img/un/r/2.gif"></td>
<td>Molis:</td><td align="right"><b>960&nbsp;</b></td><td>per valandÄ</td>
</tr>
<tr>
<td><img class="res" src="img/un/r/3.gif"></td>
<td>Geležis:</td><td align="right"><b>1200&nbsp;</b></td><td>per valandÄ</td>
</tr>
<tr>
<td><img class="res" src="img/un/r/4.gif"></td>
<td>GrÅ«dai:</td><td align="right"><b>786&nbsp;</b></td><td>per valandÄ</td>
</tr>

</table></div><div id="ltrm">

<div class="f10 b">&nbsp;KarinÄs pajÄgos:</div><table class="f10"><tr><td><a href="build.php?gid=16"><img class="unit" src="img/un/u/2.gif" border="0"></a></td><td align="right">&nbsp;<b>101</b></td><td>pretorionai (-ų)</td></tr></table></div></div></div></div></div><div id="lright1"><a href="dorf3.php"><span class="f10 c0 s7 b">GyvenvietÄs:</span></a><table class="f10"><tr><td class="nbr"><span class="c2">•</span>&nbsp; <a href="?newdid=100123422" class="active_vl">Town3</a></td><td class="right"><table class="dtbl" cellspacing="0" cellpadding="0">
<tr>
<td class="right dlist1">(56</td>
<td class="center dlist2">|</td>
<td class="left dlist3">25)</td>
</tr>
</table></td></tr><tr><td class="nbr"><span>•</span>&nbsp; <a href="?newdid=12">Town1</a></td><td class="right"><table class="dtbl" cellspacing="0" cellpadding="0">
<tr>
<td class="right dlist1">(56</td>
<td class="center dlist2">|</td>
<td class="left dlist3">26)</td>
</tr>
</table></td></tr><tr><td class="nbr"><span>•</span>&nbsp; <a href="?newdid=531112">Town2</a></td><td class="right"><table class="dtbl" cellspacing="0" cellpadding="0">
<tr>
<td class="right dlist1">(62</td>
<td class="center dlist2">|</td>
<td class="left dlist3">23)</td>
</tr>
</table></td></tr></table></div></div><div id="lres0">
<table align="center" cellspacing="0" cellpadding="0"><tr valign="top">
<td><img class="res" src="img/un/r/1.gif" title="Mediena"></td>
<td id=l4 title=750>17053/45700</td>
<td class="s7"> <img class="res" src="img/un/r/2.gif" title="Molis"></td>
<td id=l3 title=960>8209/45700</td>
<td class="s7"> <img class="res" src="img/un/r/3.gif" title="Geležis"></td>
<td id=l2 title=1200>5006/45700</td><td class="s7"> <img class="res" src="img/un/r/4.gif" title="Grūdai"></td>
<td id=l1 title=786>1049/14400</td>
<td class="s7"> &nbsp;<img class="res" src="img/un/r/5.gif" title="Grūdų sunaudojimas">&nbsp;534/1320</td></tr></table>
</div><div id="ltime">Atnaujinta per <b>103</b> ms<br>Serverio laikas: <span id="tp1" class="b">18:45:46</span> </div>
<div id="ce"></div></body>
</html>

Share this post


Link to post
Share on other sites



Found the problem, somehow AutoIT sees the source differently and thats ODD.

The line became:

<a class=active_vl herf="......>

Would like to know why...

Share this post


Link to post
Share on other sites

Just check the exact characters in the sourcecode with an HExEditor to see where the differrence is.

You will have to post the original file to enable us to test.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

works for me:

Global $text = FileRead(FileOpen(@ScriptDir & '\test.html', 0))
ConsoleWrite($text & @CRLF)
$Line = StringReplace($text, ' class="active_vl"', "@@@@@@@@@@@@@@@@@@@@@@@@@")
ConsoleWrite("!----" & @CRLF)
ConsoleWrite("!--- " & @extended & @CRLF)
ConsoleWrite("!----" & @CRLF)
ConsoleWrite($Line & @CRLF)

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0