Jump to content


Photo

string.search working incorrectly


  • Please log in to reply
3 replies to this topic

#1 Volte

Volte
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 27 April 2006 - 05:23 AM

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:

data.search("<a href=\"/tvpdb?")
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:

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

Thanks a lot
UNIX ALL THE WAY BABY!

#2 GBS

GBS
  • Members
  • PipPipPip
  • Advanced Member
  • 108 posts

Posted 27 April 2006 - 11:39 AM

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,,
Sorry for my english,... I do my best, but sometimes,...
1st intention: understand the problem
2nd intention: try to solve it
3rd intention: try to understand how to solve it :)

#3 Volte

Volte
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 27 April 2006 - 11:46 AM

Pop this:
<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">

Into a variable, and then try and do:

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

alert([the variable you put it into].search("<a href=\"tvpdb?"));
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.
UNIX ALL THE WAY BABY!

#4 GBS

GBS
  • Members
  • PipPipPip
  • Advanced Member
  • 108 posts

Posted 27 April 2006 - 04:29 PM

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\\?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,,
Sorry for my english,... I do my best, but sometimes,...
1st intention: understand the problem
2nd intention: try to solve it
3rd intention: try to understand how to solve it :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users