Follow us on Twitter!
The important thing is not to stop questioning. - Albert Einstein
Monday, April 21, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 31
Guests Online: 30
Members Online: 1

Registered Members: 82851
Newest Member: darthvador
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Regex Question


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-02-09 21:31
Hey can you guys help me out with this code? Basically I want to check a site for part of a word and then echo out the entire word. So for example say I have:

Code
<?php
$url = file_get_contents("http://www.google.com","r");
$pattern = '/ages/';
if (preg_match($pattern,$url))
{
echo "its here";
}
else
{
echo "not here";
}
?>




I'm looking for the string "ages" and I then want to echo out the full word, which, in this case, would be images. It's easy enough to see if the string exists on the site, but I have no idea how to get the whole word. Do you guys have any ideas how to do this? Thanks


Author

RE: Regex Question


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-02-09 22:09

That's very... Stupid code. Anyway.

I agree, but it's simple which is why I gave it as an example...
Are you saying just to replace
Code
$pattern = '/ages/';



to
Code
$pattern = "/([a-zA-Z]*)ages/";



I'm not trying to just see if a word ending with 'ages' exists on the page (if i was I would just change the pattern to '/[a-z]*ages/i', which is basically what you had).
I want to first see if the string 'ages' exists on the page, and then if it does, store the whole word that the string belongs to into a variable.

If for some reason I'm still not clear about what I'm trying to do (or if I'm not getting what you're saying), post back and I'll try to explain it again.


Author

RE: Regex Question

spyware
Member



Posts: 4192
Location: The Netherlands
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 11-02-09 22:48
Scan for the word ages, if it exists, scan for the two spaces "beside" the word and include everything from space #1 before "ages" to space #2 after "ages".



img507.imageshack.us/img507/3580/spynewsig3il1.png
"The chowner of property." - Zeph
[small]
Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
[/s

Edited by spyware on 11-02-09 22:55
http://bitsofspy.net
Author

RE: Regex Question


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-02-09 23:16
Alright thanks spyware