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
RE: Regex Question
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
$pattern = '/ages/';
$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.