
![]() |
vsloathe
So I have something that looks like this:
<img width="200" alt=" Visual verification " src="https://www.google.com/accounts/Captcha?ctoken=eCI-mpFKU7KVD686adRtY0DXsO4cT47Tz5ppJAQ4wlxQmUM3UxQVTenyu7q_B8c4Z3-OjKbxz5tKN_CCqgnQ-A%3A1LJioaIRWBQquEyujywtZA" height="70"> And this regexis not working. I thought I was pretty decent withregex. Anyone see any obvious clues as to why it's not working?preg_match("/alt=" Visual verification " src="(.*?)"/",$page,$out); I recently changed it from this: preg_match_all('/"(.+?aptcha?ctoken=.+?)"/',$page,$out); to see if it would make a difference. thedarkness
<? php$target = <<< EOF <img width="200" alt=" Visual verification " src="https://www.google.com/accounts/Captcha?ctoken=eCI-mpFKU7KVD686adRtY0DXsO4cT47Tz5ppJAQ4wlxQmUM3UxQVTenyu7q_B8c4Z3-OjKbxz5tKN_CCqgnQ-A%3A1LJioaIRWBQquEyujywtZA" height="70"> EOF; $ regex= "/alt=" Visual verification " src="(.*?)"/";preg_match_all( $ regex, $target, $matches );print_r( $matches ); ?> outputs; Array ( [0] => Array ( [0] => alt=" Visual verification " src="https://www.google.com/accounts/Captcha?ctoken=eCI-mpFKU7KVD686adRtY0DXsO4cT47Tz5ppJAQ4wlxQmUM3UxQVTenyu7q_B8c4Z3-OjKbxz5tKN_CCqgnQ-A%3A1LJioaIRWBQquEyujywtZA" ) [1] => Array ( [0] => https://www.google.com/accounts/Captcha?ctoken=eCI-mpFKU7KVD686adRtY0DXsO4cT47Tz5ppJAQ4wlxQmUM3UxQVTenyu7q_B8c4Z3-OjKbxz5tKN_CCqgnQ-A%3A1LJioaIRWBQquEyujywtZA ) ) Not sure what the problem is here dude..... Cheers, td vsloathe
You're telling me. I check the variable that contains the page with that string ($page), and it all looks perfectly fine. For whatever reason, the
regexis just not parsing that stuff out though.perkiset
So you're saying that the exact same code, which can process it out of page like TD's example here, does not work when it's on-page (in $page)?
If that's so, can you paste the entire buffer of a page here and the exact chunk of code that went to get it and let's give'r a whirl... unless there's a multiline thing or some other regex-behavior issue it's hard to see from this little bit of info what is going on...nutballs
my guess was going to be multiline issues as well. not sure how
regexinPHPhandles multilines, but it was in issue inASP. (i think)(perkiset
in
PHPthe default isPERLregexbehavior, meaning that if you want to do cross-line-boundary patterns you need to add the m modifier ie., preg_match('/apattern/m', $inStr);vsloathe
It's a LONG page with a lot of javscript (if you can't tell by the short sample, it's gmail). Here's a sample:
<tr> <td valign="top"> <span class="gaia cud cl"> Word Verification: </span> </td> <td> <table> <input type="hidden" id="newaccounttoken" value="Q7mdu2BAPFi8ymw3xiqM52gWU1k_YII7KFYMOUHVJPh68EZG7R9tRHYTOp6VTmtl:WD1BvkO-1W6VqBm3zZb9hg" name="newaccounttoken"> <input type="hidden" id="newaccounturl" value="https://www.google.com/accounts/Captcha?ctoken=Q7mdu2BAPFi8ymw3xiqM52gWU1k_YII7KFYMOUHVJPh68EZG7R9tRHYTOp6VTmtl%3AWD1BvkO-1W6VqBm3zZb9hg" name="newaccounturl"> <tr> <td valign="top"></td> <td valign="top"> <span class="gaia captchahtml desc"> Type the characters you see in the picture below. </span> <div> <img width="200" alt=" Visual verification " src="https://www.google.com/accounts/Captcha?ctoken=Q7mdu2BAPFi8ymw3xiqM52gWU1k_YII7KFYMOUHVJPh68EZG7R9tRHYTOp6VTmtl%3AWD1BvkO-1W6VqBm3zZb9hg" height="70"> </div> <input type="hidden" id="newaccounttoken_audio" value="-OQel7eOrsxFfpMEnYhvAIVmofWUhISS89bP5y1T1c97ZdAxWSqCv5rGVhbX4k0SZ3-OjKbxz5tKN_CCqgnQ-A:tjZk1zOqexxSk3SykcIfHw" name="newaccounttoken_audio"> <input type="hidden" id="newaccounturl_audio" value="https://www.google.com/accounts/Captcha?ctoken=-OQel7eOrsxFfpMEnYhvAIVmofWUhISS89bP5y1T1c97ZdAxWSqCv5rGVhbX4k0SZ3-OjKbxz5tKN_CCqgnQ-A%3AtjZk1zOqexxSk3SykcIfHw" name="newaccounturl_audio"> <div id="snd1"></div><div id="noEm"></div> <div id="playAudio"></div> </td> </tr> thedarkness
I've seen the gmail code, it's a massive one-liner pretty much. Wonder if preg_match is barfing on the fact that there are no line breaks (which would be a bug that should be documented). Just a thought.
Cheers, td BTW, that sample works fine in my test rig as well. vsloathe
Well if any of you feel so inclined, it would give you a chance to see the actual problem if you grabbed the gmail page at https://mail.google.com/mail/signup and checked the code against that.
thedarkness
I'm on it VS, hang tough my brother from another mother.
Cheers, td thedarkness
Hate to tell you this VS but I followed your link to the Gmail signup page in FF, viewed source, pasted into the above code and ran it and it performed flawlessly AFAICS. Extracted this one link;
https://www.google.com/accounts/Captcha?ctoken=VoJLcsVl0CJZ8u7Roflt9nmU_WOgSi-Mf_rUsd9OYEd4ZfQtAhJzdNFqpaM456J9%3ASExuqDKDeMvyy_e58Afj_Q There is obviously something going on here that we're missing........ ![]() Cheers, td vsloathe
It could very well be my friend's hosting that he's running it on. I will have to test it on mine when I get a spare second.
Thanks homes. -V |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads