Jump to content

Recommended Posts

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!

  • Like 1
Link to comment
https://forums.phpfreaks.com/topic/302637-need-help-finding-right-pattern/
Share on other sites

  • 2 weeks later...

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 by .josh
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.