ghostdog74
-
Posts
84 -
Joined
-
Last visited
Never
Posts posted by ghostdog74
-
-
Thanks a ton.
Does this work if the image has a PNG or other image types?
i have not specifically harded any image file type. as you can see, my code searches for "img class" , therefore, if the link is to a png file, it should still grab for you
-
no need regex. simple split will do
$string = "success adding the records in the river table by scvinodkumar today at 6.36 pm by scvinodkumar [[Category:Test]]"; $s = explode("[[Category:Test]]",$string); print $s[0];
-
$string = '1051 JoZlkA11215'; $s = preg_replace("/[^a-zA-Z]+/","",$string); print $s;
-
just use normal string functions
$url = "http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=6221"; $page = strip_tags(file_get_contents($url),"<img>"); $p = explode("/>",$page); foreach($p as $k=>$v){ if(strpos($v,"img class=")!==FALSE) { $jpg = explode("src=",$v); $imagelink = preg_replace("/\"/","",$jpg[1]); #remove doublequotes print "imaglink " . $imagelink; $image = file_get_contents($imagelink); $f=fopen("friend.jpg","w"); fwrite($f,$image); fclose($f); } }
-
$fp = "[Querying whois.arin.net] [Redirected to whois.ripe.net:43] [Querying whois.ripe.net]"; $a = preg_split("/Querying/",$fp); print end($a);
-
ctype_alnum doesn't evaluate to true when there are spaces involved, so this would mean messages cannot have spaces.
i only looked at his first post. if its not what he wants, then so be it.
-
advance thank you.
how the hell it letting the @ in, when only a-z 0-9 are allowed only.
madness
<?php $message="my name is @ redarrow"; $err="Sorry you have not filled in the form correctly!"; if(!preg_match("/[a-z0-9]/i",$message)){ echo $err; }elseif(empty($message)){ echo $err; }else{ echo $message; } ?>
$message="my name is @ redarrow"; if ( ctype_alnum ($message) ){ print "$message is alphanumeric\n"; }else{ print "'$message' is not alphanumeric\n"; }
-
Is there any way I can keep sendmail off and still use the mail() function to send mail to my external mail server for action.
you do not need to start a mail service if all you are doing is sending out mails.
-
Now there is a tool named nail which can also send mail without using the sendmail so my code looks like this as a sample
<?php
$message="Hi test";
system('cat $message | /usr/local/bin/nail -r monsrv@abc.com -s "Test Mail with Nail" tanveer@abc.com')
?>
i would advise against using external shell tools like that as it makes your code not portable. whenever and wherever you can, always try to use PHP's mail methods/classes. Here it has example of how to send html email. I am also sure that if you search hard enough you can find lots of examples on the net.
-
I imagine it would have something to do with {2} or something like that.
you are about there. but that says match 2 spaces. if there are 2 or more spaces, you can use {2,}
-
Thanks ghostdog,
Someone brought parse_str() to my attention. Checkout http://us2.php.net/manual/en/function.parse-str.php
good. the bottom line is, PHP provides you numerous string functions you can use, regex should be the last thing that comes to your mind.
-
Correct, but it doesn't provide you with any other information that is useful such as permissions, ownership, modified time, etc. That is why I am doing it this way.
have you read the manual? see ftp_rawlist() function.
-
replace the newline with space.
$a = preg_replace("/\n/"," ",$find);
then continue your checking.
-
how about this, no regex
$docName="Ap%praisal Agreement"; $a = explode(" ",$docName); if ( count($a) == 2){ print "ok, space in between\n"; } if ( ctype_alnum ($a[0]) ){ print "$a[0] is alphanumeric\n"; }else{ print "$a[0] is not alphanumeric\n"; } if ( ctype_alnum ($a[1]) ){ print "$a[1] is alphanumeric\n"; }else{ print "$a[1] is not alphanumeric\n"; }
-
ghostdog74, it seems like your script will return an array rather than distinct variables holding strings. Is that right?
yes, that's right. if you don't need arrays, then after exploding on the "&", the array will contain 3 elements. that's all you need.
What do you think of this one? I got it from another source but it looks like gibberish to me (seems to work though)
$querystring = 'height=6&weight=170&eyes=brown'; preg_match_all("/(.*?)=(.*?)(&|$)/", $querystring, $matches); for ($i = 0; $i < count($matches[0]); $i++) $$matches[1][$i] = $matches[2][$i];
if you don't understand what its doing in the first place, then don't use it. regular expressions , although powerful, tends to make things look "gibberish". Even worse if you are not well trained in regex. Being more expressive in your codes will make your life easier next time, both in the area of maintenance and code troubleshooting.
-
$string="height=6&weight=170&eyes=brown"; $s = explode("&",$string); foreach( $s as $k=>$v){ $v=explode("=",$v); $a[$v[0]]=$v[1]; } print_r($a);
-
ghostdog74,
The reason why I can't use those is that this information comes from a FTP connection (via a socket). I didn't see any information in FTP functions on getting the file permissions.
ok , so you are listing files from inside an FTP session? PHP has almost any kind of libraries you need to make life easy for you. check out the FTP module. you can use ftp_nlist() function to list files from remote server, then get the results and manipulate them as you wish.
-
why don't you use PHP readdir() and fileperms() ??
some things you just have to keep simple.
-
then how about just explode().
-
Now, I just want a regex to remove "Date:" and just display
Wed, 24 Dec 2008 01:52:41 GMT
How come above is not working?
Just split the string and put a limit on the split.
$string = "Date: Wed, 24 Dec 2008 01:52:41 GMT"; $a = split(" ",$string,2); print "What i want is $a[1]\n";
-
Hello,
I'm having a problem trying to match pipe characters if there is more than one:
$string = '{hyperlink|ahref|text}'; if ( substr_count($string,"|") > 1 ) { echo "yes, more than 1\n"; }
-
Hello.
I'm trying to extract the image src value.
when parsing XML/HTML, its better to use dedicated classes/methods (if you have them) than constructing regex from scratch.
$string = '<a name="poster" href="/rg/action-box-title/primary-photo/media/rm118396416/tt0811080" title="Speed Racer"><img border="0" alt="Speed Racer" title="Speed Racer" src="http://ia.media-imdb.com/images/M/MV5BMTA5MjgxMDE4OTVeQTJeQWpwZ15BbWU3MDgyNjc4NjE@._V1._SX94_SY140_.jpg" /></a>'; if ( ($start = strpos($string,'<a name="poster"' ) ) !==FALSE ) { $xml = new SimpleXMLElement($string); echo $xml->img['src']; }
-
You might want to read the entire thread Ghostdog.. that issue has already been solved..
i am providing another way to solve that issue without messy regexp. What's wrong with that?
-
Unsolved this because I discovered an issue
It's matching the entire string, for example
function LoadGif($imgname)
Only LoadGif($imgname) should be found and made bold, however it's also pulling in everything to the left of that too
Any ideas on how to make it not go back like that?
split the string on space, go through each word and find "(" and ")".
$string = 'function LoadGif($imgname)'; $s = explode(" ",$string); foreach ($s as $k=>$v){ if ( strpos($v,"(") !== FALSE && strpos($v,")") !==FALSE){ echo "Found : $v\n"; } }
Help with RegEx replace
in Regex Help
Posted
i don't understand what you mean by "no matter where it is", but anyhow, here's something non regex
,