/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] PREG – Numeric ranges

I am trying to make some preg rules to match credit card bin ranges.

Is there an easy way to format a match on any number between 11 and 55 including 11 and 55 themselves?

[code]
[1-5][1-5] // this would not match 10 or 16
[1-5][0-9] // this would match 10 and 56
[11-55] // I think this matches 1 followed by 1-5 followed by 5?
[/code]

All of the above are incorrect and any advice would be great.

Cheers.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 24.2007 — <i>
</i>(1[1-9]|[2-4][0-9]|5[0-5])
Copy linkTweet thisAlerts:
@MrCoderauthorApr 24.2007 — Is there a cleaner way, or is this as clean as it gets?
Copy linkTweet thisAlerts:
@bokehApr 24.2007 — Is there a cleaner way, or is this as clean as it gets?[/QUOTE]Not with a regex. The only why I can see to shorten it is:[CODE]([2-4]d|1[1-9]|5[0-5])[/CODE]Also changing the order as above would make it more efficient.
Copy linkTweet thisAlerts:
@MrCoderauthorApr 25.2007 — I wonder if there is another way.
Copy linkTweet thisAlerts:
@bokehApr 25.2007 — I wonder if there is another way.[/QUOTE][code=php]if(10 < $YourNumber && 56 > $YourNumber)[/code]
×

Success!

Help @MrCoder spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...