|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I have a user form that instructs the user to input a hex string (ie. 1A:33
4:5F:CC)I need to validate that each character entered is a valid hex character 1-9 A-F. Any ideas of how to do this effeciently? My current code breaks the string into individual characters and checks them in a foreach loop with the hex values in an array...this seems to be ineffective. Thanks |
|
#2
|
|||
|
|||
|
use the m// operator
if($test_var =~ m/(d|w)/) {$good = 1} else {$good = 0;} |
|
#3
|
|||
|
|||
|
Thanks worked great...
Used the following to check hex value: if($in1 =~ m/[1-9]/) {$good = 1;} else {$good = 0;} if ($good == 0) { if($in2 =~ m/[A-F]/) {good = 1;} else {$good = 0;} } |
|
#4
|
|||
|
|||
|
N/P
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Validating characters - Hex |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|