How to match numbers ranging from 400 to 550 with regex?

I want to validate a numeric string that must only contain numbers ranging from 400 to 550.

$x = "401";  // valid 
$x = "551";  // invalid 

I want to only match the numbers between 400 and 550.

I tried the following pattern:


But it doesn't work.

What is the regex pattern for matching numbers 400-550?


A regex-way to validate this range:


See demo. It will also work in larger texts since \b boundaries are used. In case of whole strings, use ^ and $ around instead of \b.

Need Your Help

session authentication between ajax and php

php javascript html ajax session

I'm wondering what the typical way storing a session would be, so that you could not just typing in and insert something into a database. Currently I do ...

Fill two image overlay like seekbar on touch event of image-view

android android-imageview seekbar gauge

There are two image black and blue while touching on blue image it should fill like progress, I achieved using multiple cuts images without using canvas but not get smoothness on touch, like 100 Pu...