Home > utils > prt_checkAlphaNumUnder.m

prt_checkAlphaNumUnder

PURPOSE ^

check whether a given string is alphanumerical or underscore

SYNOPSIS ^

function out=prt_checkAlphaNumUnder(s)

DESCRIPTION ^

 check whether a given string is alphanumerical or underscore
 FORMAT out =  prt_checkAlphaNumUnder(s)
 Inputs:
   s - a string of arbitrary length to check
 Output:
   out - logical 1 if the all chars in the string are alphanumerical
         logical 0 otherwise
 
 Based on isalpha_num in the identification toolbox
__________________________________________________________________________
 Copyright (C) 2011 PRoNTo

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out=prt_checkAlphaNumUnder(s)
0002 % check whether a given string is alphanumerical or underscore
0003 % FORMAT out =  prt_checkAlphaNumUnder(s)
0004 % Inputs:
0005 %   s - a string of arbitrary length to check
0006 % Output:
0007 %   out - logical 1 if the all chars in the string are alphanumerical
0008 %         logical 0 otherwise
0009 %
0010 % Based on isalpha_num in the identification toolbox
0011 %__________________________________________________________________________
0012 % Copyright (C) 2011 PRoNTo
0013 
0014 %--------------------------------------------------------------------------
0015 % Written by J.Richiardi
0016 % $Id: prt_checkAlphaNumUnder.m 247 2011-11-01 15:49:23Z jrichiar $
0017 
0018 % sanity check
0019 if ~ischar(s)
0020     error('Input is not a string');
0021 end
0022 
0023 for i=1:length(s)
0024     out=~isempty(findstr(upper(s(i)), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'));
0025     if out==false
0026         break;
0027     end
0028 end

Generated on Sun 20-May-2012 13:24:48 by m2html © 2005