cancel
Showing results for 
Search instead for 
Did you mean: 

UDF

praveenreddy_bk
Participant
0 Kudos

Hi Frnds,

I need UDF for checking for non-numeric( like it starting with negative number ),alphanumeric, if its null, if it having 00000's

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

this will be the code

try  
{  
Integer.parseInt(input);  
 return true;  
}  
catch( Exception e )  
{  
 return false;  
}

Answers (2)

Answers (2)

GabrielSagaya
Active Contributor
0 Kudos

public String isAlphaNumeric(String a,Container container){

boolean isInteger = false;

try{

int i = Integer.parseInt(a.trim());

isInteger = true;

}

catch(NumberFormatException e){

isInteger = false;

}

String ret = "";

if(isInteger){

ret = u201CNumerical Charactersu201D;

}

else{

ret = u201CAlphaNumerical Charactersu201D;

}

return ret;

}

0 Kudos

Hi,

try the following code

String in = "868686123";

if(in.length()>0 && in.matches(" \ \ d*")){

return in;

}

else

throw new RuntimeException("Non-numeric");

}

With Regards

Venkat

Former Member
0 Kudos

Hi Praveen,

Take input parameter is a.

if ( a == NULL) // For Checking the NULL value

return "null value";

else if(a.matches("
p+")) // It is pattern for Checking the Alpha Numeric or not,

return "alpha Numeric";

else

if (a < 0) return " Negative number"; // For Checking the value is it negative or not

else return "Positive Number";

Here we have to import java.util.regex.*;

For more info

http://leepoint.net/notes-java/data/strings/40regular_expressions/26pattern-matcher.html

Regards

Ramesh