Jump to content

string.search working incorrectly


Volte

Recommended Posts

Hey, pulled some info from my page, only, when I search for a specific string, it cant find it, I keep chopping characters off the end of the string that I am searching for, and it takes me up to this:

[code]data.search("<a href=\"/tvpdb?")[/code]
Any other characters after this (even when I know for a fact they DO exist) returns -1 (I "alerted" the results of the search, -1 means it wasn't found).

The string is part of a url, and I'm actually searching for this entire part, but it will not cooperate:

[code]data.search("<a href=\"/tvpdb?d=tvs&id=")[/code]
Any tips, insights, ideas, solutions?

Thanks a lot
Link to comment
Share on other sites

Pop this:
[code]<div class="chan">
<h2><a href="/tvpdb?d=tvs&id=166030801&channels=us_KTVU&lineup=us_CA04931d&.intl=us">FOX<br>2</a></h2>
<h2 class="right"><a href="/tvpdb?d=tvs&id=166030801&channels=us_KTVU&lineup=us_CA04931d&.intl=us">FOX<br>2</a></h2>
<ul class="chan">[/code]

Into a variable, and then try and do:

[code]alert([the variable you put it into].search("<a href=\"tvpdb?d="));[/code]
and then do:

[code]alert([the variable you put it into].search("<a href=\"tvpdb?"));[/code]
and watch the results. Look closely at those last two lines of code. Boggles my mind why it wont work.

EDIT: Ok I think I narrowed it down to the "?", but why? and how do I overcome this. Any solutions? I've tried escaping it of course: "\?" but that doesnt help. >.< Grrr.
Link to comment
Share on other sites

Ok, thanks for the explains,, it's now more clear to me, about the 'search' function, (I usually parse in php,...)

Try that one,,
-----
data.search("<a href=\"/tvpdb[b]\\[/b]?d=tvs");
-----
It should do the job,, ;)

"?" is a magic/special character,, & it seems we need to add 2 "\" to include it,...

Hoping it helps,,

l8tr,,
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.