Brandon_R Posted July 31, 2009 Share Posted July 31, 2009 Hello, i need a regular expression to validate that an entered string only contains hex values. preg_match Thank you Brandon_R Quote Link to comment Share on other sites More sharing options...
Adam Posted July 31, 2009 Share Posted July 31, 2009 /^0x[0-9A-F]{1,4}$/i Source: http://www.perlmonks.org/?node_id=629540 Quote Link to comment Share on other sites More sharing options...
.josh Posted July 31, 2009 Share Posted July 31, 2009 that will only match if there is one hex value, though. You said values so you will have to provide an example of how they are delimited. space? comma? etc...(show an actual example of content) Quote Link to comment Share on other sites More sharing options...
Brandon_R Posted July 31, 2009 Author Share Posted July 31, 2009 Just an 7 or 8 value long hex string such as 123ADF22 The input field is <input type="text" name="hex" value="" maxlength="8" /> Brandon+R Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted July 31, 2009 Share Posted July 31, 2009 Well hex values typically start with 0x. What you've provided is just a series of hex digits. So based on your latest post: preg_match( '/[a-fA-F0-9]{1,8}/', $value ) 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.