Volte Posted April 27, 2006 Share Posted April 27, 2006 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 https://forums.phpfreaks.com/topic/8527-stringsearch-working-incorrectly/ Share on other sites More sharing options...
GBS Posted April 27, 2006 Share Posted April 27, 2006 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,, Link to comment https://forums.phpfreaks.com/topic/8527-stringsearch-working-incorrectly/#findComment-31273 Share on other sites More sharing options...
Volte Posted April 27, 2006 Author Share Posted April 27, 2006 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 https://forums.phpfreaks.com/topic/8527-stringsearch-working-incorrectly/#findComment-31276 Share on other sites More sharing options...
GBS Posted April 27, 2006 Share Posted April 27, 2006 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 https://forums.phpfreaks.com/topic/8527-stringsearch-working-incorrectly/#findComment-31366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.