Jump to content

Archived

This topic is now archived and is closed to further replies.

Volte

string.search working incorrectly

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

Share this post


Link to post
Share on other sites
Hi there,,

Maybe some code could help us to understand the problem,,...
Thanks to add some more infos, about your "data.search" function,,... we could then do some more test,,

l8tr,,

Share this post


Link to post
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.

Share this post


Link to post
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,,

Share this post


Link to post
Share on other sites

×

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.