siddscool19 Posted September 5, 2008 Share Posted September 5, 2008 I am not able to get this statement? ereg_replace('/$', '', dirname($_SERVER['PHP_SELF'])) I want to know what does '/$' means here? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 5, 2008 Share Posted September 5, 2008 / at the end of the line is what it means... that line removes a trailing slash if it exists. file.com/stuff/cake/ becomes file.com/stuff/cake Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Can u please tell me from where to get such information? I am not able to find it anywhere ??? Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Please also tell me what does it means preg_match('%http://rapidshare.com/(.*)%', $line, $rapidurl); I mean please tell me the use of this '%' (.*) Thanks in advance Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Can please someone help my coding is on hault I know that i should wait but sorry to post again Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 5, 2008 Share Posted September 5, 2008 These are regular expressions. Look it up in the fine manual. Did you write this code. If so, why are you using something you don't understand? If you didn't, why are you using something you don't understand? Ken Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Sir, I have learned all the basics and was trying to learn more through codings... And i came up with this and terms such as (.*) can't be search on google so i prefered to ask here. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 5, 2008 Share Posted September 5, 2008 If you have a PHP function you don't understand, the best place to find out about it is in the online PHP manual, not google. Just use a URL like http://www.php.net/function_name_here and you will be taken to the correct place. Ken Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Sir, I am not able to get the meaning of % and (.*) from there can you please explain me? Sorry for asking for help again and again and ya since its not a function i can't use that url on it but surely for functions i will use it thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 5, 2008 Share Posted September 5, 2008 Look around on this page. You're trying to use the function preg_match, so look there. Ken Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Sir, When we use (.*) with preg_match I noticed that only the text after this sign is copied to array is this is its functions? Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Can someone please tell me how to use url in a preg_match When i was writing code: preg_match("http://rapidshare.com/",$link,$rs); It gave me following error: Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in C:\xampp\htdocs\rs\2.php on line 35 What should i do to remove this error? Also i want to know how to get a particular part of a line in the array using preg_match Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted September 5, 2008 Share Posted September 5, 2008 Yes, the dot is a metacharacter that matches anything that is not a newline. So in your example: preg_match('%http://rapidshare.com/(.*)%', $line, $rapidurl); The pattern first will be required to match the following characters in sequence: http://rapidshare.com/ (ah.. be careful about that dot in the url.. in this case, the regex engine is not looking to match a dot, but again, any character that is not a newline chartacter.. you will need to escape that dot (\.) So then, assuming all of this matches, your (.*) will continue on matching anything that is not a newline character. Very straight forward stuff. I agree with the moderator.. best to look stuff up in the php.net manual. There is a text field along the top that allows you to type in any function or language construct and the manual will point you to the right place (assuming you spelled it correctly) Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Can u please tell me how to get a particular part of a line using preg_match? One more thing whats the use % ? One more thing whats a new line character i guess its \n am i right? Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted September 5, 2008 Share Posted September 5, 2008 Can u please tell me how to get a particular part of a line using preg_match? One more thing whats the use % ? One more thing whats a new line character i guess its \n am i right? The % character is called delimiter (you need delimiters in your Perl Compatible Regular Expressions (which is what PHP uses)). I can tell you are the kind of person who wants to learn by taking initiatives and accepting any help others offer.. so I point to this link as a tutorial on PCRE: http://devzone.zend.com/node/view/id/1247 Please take the time to review this link.. it will help you out with the basics. At this point, don't worry about 'how to get a particular part of the line using preg_match'.. I would focus on the basics and build from there.. then you will actually understand the code you are working with. Trust me, it will pay off in the long run. Cheers, NRG EDIT.. I noticed some of the links in the link I posted don't seem to be working, but at least the top half of the site should be helpful in getting you started. I'm sure other mods / members can provide some other links as well (as kenrbnsn has done). Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Thanks man I wanted kinda like this reply only I will surely read on that page and learn basics first and if any query can i ask then ? Quote Link to comment Share on other sites More sharing options...
siddscool19 Posted September 5, 2008 Author Share Posted September 5, 2008 Can someone please provide me with some more detailed and simple source for PCRE? Quote Link to comment Share on other sites More sharing options...
effigy Posted September 5, 2008 Share Posted September 5, 2008 Look here. Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted September 5, 2008 Share Posted September 5, 2008 Damn! I completely overlook / forget about those locked sticky threads! I'll be more mindful to think of those next time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.