Hello guys,
I have a requirement where user can enter 0-9, a-z, A-Z, / but when user enters other special characters it should get removed.
Sample:
1234acv → 1234acv
1234/ → 1234/
1234@ → 1234
1234!@ad → 1234ad
Hello guys,
I have a requirement where user can enter 0-9, a-z, A-Z, / but when user enters other special characters it should get removed.
Sample:
1234acv → 1234acv
1234/ → 1234/
1234@ → 1234
1234!@ad → 1234ad
@ChakilamG You need to write an Edit Validate and embed it in the property itself.
The code should have a replace function like this, which will automatically replace the non-alphanumeric characters:
input.replaceAll("[^a-zA-Z]+","");
Hi @ChakilamG,
Create a function similar to removeSpecialChars and add below code in that.
StringBuffer OutputString = new StringBuffer(aInput);
for (int i = 0; i < OutputString.length(); i++) {
if ((!Character.isUnicodeIdentifierPart(OutputString.charAt(i))) && ((OutputString.charAt(i)!='/'))) {
OutputString.setCharAt(i, '_');
}
}
return OutputString.toString();
This function will take input string and replaces special characters except ‘/’ with _
In your DT activity have function like this @replaceAll(@removeSpecialChars1(String),‘_’,‘’)
Thanks,
Vinay
Note:
StringBuffer OutputString = new StringBuffer(theValue);
for (int i = 0; i < OutputString.length(); i++) {
if ((!Character.isUnicodeIdentifierPart(OutputString.charAt(i))) && ((OutputString.charAt(i)!='/'))) {
OutputString.setCharAt(i, '_');
}
}
String data=OutputString.toString();
data = data.replaceAll("_", "");
theValue=data.toString();
Thanks,
Vinay