LazyCylindric Posted November 29, 2016 Share Posted November 29, 2016 Hey, guys. Sorry, if this sound like a stupid question to you, but I am really not good with regular expressions. I want to match full number, slash and 900000. So, the pattern is: [number]/[slash][any_umber or exactly 900000] Igoogled for a while, and tried this: $regex = '#[0-9]/[0-9]#'; However, it doesn't work as I want. Please help! 1 Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 29, 2016 Share Posted November 29, 2016 Preg_match is your friend. Read the manual. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 29, 2016 Share Posted November 29, 2016 Just [0-9] (or \d for short) will only match a single digit. If you want one or more then use +. Not sure how the "any number or exactly 900000" is supposed to work. Isn't 900000 a number too? Quote Link to comment Share on other sites More sharing options...
.josh Posted December 13, 2016 Share Posted December 13, 2016 (edited) At face value, this should work for you: preg_match('~^\d+/\d+$~',$subject,$match); if ($match) { // matched, do something } but i have a sneaking suspicion you aren't telling us the whole story/requirements. Edited December 13, 2016 by .josh 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.