bilis_money Posted June 18, 2006 Share Posted June 18, 2006 hi, i'm really very new to REGEXbut i think i have a basic question.and the code was;[code]preg_match ("/userfile_[1-5]{1}/", $name)[/code]what is this code do?please explain it in detail?thank you very much. Quote Link to comment Share on other sites More sharing options...
poirot Posted June 18, 2006 Share Posted June 18, 2006 Splitting it:"/" is the starting delimiter"userfile_" matchs the string "userfile_" (literal)"[1-5]" is a character class, numbers from 1 to 5"{1}" is a quantifier (1 time)"/" is the ending delimiterIt will match userfile_1, userfile_2, userfile_3, userfile_4, and userfile_5.But since there are no anchors (^ and $) this means it will also match strings with anything before and after it. Quote Link to comment Share on other sites More sharing options...
bilis_money Posted June 18, 2006 Author Share Posted June 18, 2006 hi poirot,how long you had learned REGEX?and what book do you have?is it Jeffrey Freidl's book?i guess i need more REGEX story and samples so that i can absorb them welland to be familiarize as well.thanks for your answers. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted June 19, 2006 Share Posted June 19, 2006 Buy a copy of Programming PHP first version(don't know about the second), from a company called oreilly, by the time you read through there 2-3 pages on regex, you will understand fully all of the basics of regex, until you get down to themore involved stuff, you won't be able to make your own at that point, but atleast you will know what you are reading, and have quick references, you can look up anything under there regex, perl compatible, and post ex 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.