Help with matching strings with special characters

ereinion

Member
I'm trying to write a script to see what hobo codes I have left to find:
PHP:
void main() {
    string log = visit_url("questlog.php?which=5");
    boolean allFound = true;
    string[string] areas;
    areas["The Penultimate Fantasy Airship"] = "There're no prerequisits to access the area.";
    areas["The \"Fun House\""] = "There're no prerequisits to access the area.";
    areas["The Enormous Greater-Than Sign"] = "It's only available before unlocking the Dungeons of Doom.";
    areas["The Battlefield (Frat Warrior Fatigues)"] = "It's only available during the level 12 quest.";
    areas["The Arid, Extra-Dry Desert"] = "There're no prerequisits to access the area.";
    areas["The Sleazy Back Alley"] = "There're no prerequisits to access the area.";
    areas["Thugnderdome"] = "It's only available under moxie signs (Wombat, Blender or Packrat).";
    areas["Belowdecks"] = "There're no prerequisits to access the area (but it's unavailable during the Hippy War)."; 
    areas["Camp Logging Camp"] = "It's only available under mysticality signs (Platypus, Opossum or Marmot).";
    areas["Bugbear Pens"] = "They are only available under muscle signs (Mongoose, Wallaby or Vole). It's also unavailable after beating Felonia";
    areas["The Defiled Nook"] = "The area is only available during the level 7 quest.";
    areas["The Poker Room"] = "There're no prerequisits to access the area.";
    areas["White Citadel"] = "It's only available before unlocking the citadel.";
    areas["Noob Cave"] = "There're no prerequisits to access the area.";
    areas["Cobb's Knob Menagerie, Level 3"] = "There're no prerequisits to access the area.";
    areas["The Limerick Dungeon"] = "There're no prerequisits to access the area.";
    areas["Lair of the Ninja Snowmen"] = "There're no prerequisits to access the area.";
    areas["Pre-Cyrpt Cemetary"] = "The area is only available before the Cyrpt.";
    areas["Cola Wars Battlefield (Undisguised)"] = "It is available between levels four and six.";
    areas["The eXtreme Slope"] = "There're no prerequisits to access the area.";
    
    foreach loc in areas {
        if (!log.contains_text(loc)) {
            allFound = false;
            print("You need to find the code in " + loc + ". " + areas[loc], "green");
        }
    }
    if (allFound) {
        print("You've already found all the hobo-codes", "green");
    }
}
I think it works ok-ish, though I'm not certain if all the strings match what's going to appear at the page. However I am having trouble matching one which does appear there (i.e. one I've already found), namely "The "Fun" House". As you can see I have tried escaping the quotation marks, which didn't help. Having no idea of what method I should use to get the strings to match, I am turning to you for help.

So help, please?
 
Last edited:

Theraze

Active member
Check the html code on questlog.php?which=5 to see what it actually uses. There's a decent chance you want " or something similar instead of using escaped ". If it is in fact quotation marks... you probably can't escape them. Just use them straight. But check the html first.
 

ereinion

Member
The html is (and the Fun House is in the line starting with the <centeR> tag):
HTML:
<html><head>
<script language=Javascript>
<!--
if (parent.frames.length == -1) location.href="game.php";
//-->
</script>
<script language=Javascript src="/images/scripts/core.js"></script>
<script language=Javascript src="/images/scripts/keybinds.min.2.js"></script>
<script language=Javascript src="/images/scripts/window.20111231.js"></script>
<script language="javascript">function chatFocus(){if(top.chatpane.document.chatform.graf) top.chatpane.document.chatform.graf.focus();}
if (typeof defaultBind != 'undefined') { defaultBind(47, 2, chatFocus); defaultBind(190, 2, chatFocus);defaultBind(191, 2, chatFocus); defaultBind(47, 8, chatFocus);defaultBind(190, 8, chatFocus); defaultBind(191, 8, chatFocus); }</script><script>
function font(which)
{
   document.f.font.value = which;
   document.f.submit();
}
function maxlen(textarea)
{
    var max = 5000;
    var len = textarea.value.length;
    var counter = getObj('counter');
    if (!counter)
        return;

    if (len > max)
        counter.className = "redbold";
    else
        counter.className = "";
    counter.innerHTML = len;
}
</script><script language=Javascript src="/images/scripts/jquery-1.3.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="/images/styles.20120512.css">

<script language="Javascript" src="/basics.js"></script><link rel="stylesheet" href="/basics.css" /></head>

<body>
<centeR><table  width=95%  cellspacing=0 cellpadding=0><tr><td style="color: white;" align=center bgcolor=blue><b>Your Quest Log</b></td></tr><tr><td style="padding: 5px; border: 1px solid blue;"><center><table><tr><td><Center>[<a href="questlog.php?which=1">current quests</a>]   [<a href="questlog.php?which=2">completed quests</a>]   [<a href="questlog.php?which=3">other accomplishments</a>]   [<a href="questlog.php?which=4">notes</a>]   [hobo code binder]</center><p><center><table><tr><td>You have found 12 hobo glyphs in the following zones:<ul><li>The Penultimate Fantasy Airship</li><li>The "Fun" House</li><li>The Arid, Extra-Dry Desert</li><li>The Sleazy Back Alley</li><li>Belowdecks</li><li>The Poker Room</li><li>The Road to White Citadel</li><li>Noob Cave</li><li>Cobb's Knob Menagerie, Level 3</li><li>The Limerick Dungeon</li><li>The Lair of the Ninja Snowmen</li><li>The eXtreme Slope</li></ul></td></tr></table></center><p><center><a href="campground.php">Back to your Campsite</a></center></td></tr></table></center></td></tr><tr><td height=4></td></tr></table></center></body><script src="/onfocus.js"></script></html>
So straight quotation marks as far as I can tell, but how would I put that into the string when I can't escape them?

- edit - I tried a few variants with quotation marks inside quotation marks without getting it to work, and then went back to the escaped characters which suddenly did work as I wanted it to :p I guess I must have messed up some capitalization or something in my previous attempt. Sorry for the bother :)
 
Last edited:

Theraze

Active member
Well, your example is The "Fun House" with both words captured... The html is for The "Fun" House with only the middle word captured. The two are not the same. :)
 

Theraze

Active member
Eh, we all do it sooner or later. Least you got it figured out when you started playing with quotes even if the reason why it worked had been a mystery. :)
 
Top