function strspecial, strarray, digit=digit, alpha=alpha, $ firstchar=firstchar, lastchar=lastchar, lchar=lchar, rv=rv ; ------------------ input must be string ------------------- if not data_chk(strarray,/string) then begin message,/info,"Need string or string array input..." message,/info,"IDL> truth=strspecial(strarray [,/digit,/alpha,/lastchar]) return,'' endif lastchar=keyword_set(lastchar) firstchar=keyword_set(firstchar) chkall= n_elements(strarray) eq 1 and n_elements(rv) eq 0 and $ ((1-firstchar) and (1-lastchar)) firstchar = (1-lastchar) ; make this the default if chkall then begin ; recurse (call "old" code") ; ---------------------------------------------------------------------- if n_elements(rv) eq 0 then rv=[-1] for i=0,strlen(strarray(0))-1 do rv=[rv, strspecial( $ strmid(strarray(0),i,100),first=firstchar,last=lastchar,$ digit=digit, alpha=alpha, rv=rv)] retval=rv(1:*) ; ---------------------------------------------------------------------- endif else begin ; ---------------------------------------------------------------------- ; make character array for use in comparsions fchar=strupcase(strmid(strarray,0,1)) ; first character lchar=strupcase(strlastchar(strarray)) ; last character char=([[fchar],[lchar]])(*,keyword_set(lastchar)) ; char array of interst ; generate booleans specials = strlowcase(char) eq char ; only a-z,A-Z effected digits = char ge '0' and char le '9' ; where digits alphas = 1 - specials ; ALPHAS are NOT specials case 1 of keyword_set(digit): retval=digits keyword_set(alpha): retval=alphas else: retval=(specials and (1-digits)) endcase retval = retval and strlen(char) ne 0 ; dont judge null strings ; ---------------------------------------------------------------------- endelse return,retval end