Question
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
HCL
IN
Last activity: 20 Aug 2024 2:15 EDT
How to remove spaces when we are entering number in Fiel
For India- Spaces are not aowed in the TAX number. Tax Number vaidation we can enter digits and some characters ".+>"up to 15 max
***Edited by Moderator Marije to change type from Pega Academy to Product***
-
Reply
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 9 Jan 2025 10:04 EST
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689993000/dd55a5d4-3de1-4900-bfac-295672da22a9.jpg?itok=00xMCHaI)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689993000/dd55a5d4-3de1-4900-bfac-295672da22a9.jpg?itok=00xMCHaI)
LTIMindtree
PL
above code is for Edit Input rule.
for Edit Validate try the below code and check.
theProperty.setValue(theValue.replaceAll("\\s", ""));
return true;
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2024-03/0616cffa-1530-4cde-abff-fac83e4635bf.jpg?h=658174c2&itok=sY2fYdoO)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2024-03/0616cffa-1530-4cde-abff-fac83e4635bf.jpg?h=658174c2&itok=sY2fYdoO)
Maantic Inc
IN
If string has more duplicate spaces. you can use below function with expression and it will remove all the duplicate spaces from string.
For example: Lorem Ipsum Dolor 96 and you can remove the duplicate spaces and out put is Lorem Ipsum Dolor 96
@pxReplaceAllViaRegex("Lorem Ipsum Dolor 96","\\s+"," ")
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
HCL
IN
@SohamM95 when we select India In country It show TAX id and TAX number In TAX number - when enter any thing like we can enter digits and some characters ".+>"up to 15 max. ^[\\w.+-\\/\\\\]{1,15}$
Spaces are not allowed .
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2024-03/0616cffa-1530-4cde-abff-fac83e4635bf.jpg?h=658174c2&itok=sY2fYdoO)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2024-03/0616cffa-1530-4cde-abff-fac83e4635bf.jpg?h=658174c2&itok=sY2fYdoO)
Maantic Inc
IN
What is your requirement exactly?
Updated: 23 Jul 2024 1:54 EDT
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
HCL
IN
when we select India In country It show TAX id and TAX number In TAX number - when enter any thing like we can enter digits and some characters ".+>"up to 15 max. ^[\\w.+-\\/\\\\]{1,15}$
Spaces are not allowed . By using Edit Validate rule , How can we write java code for removing spaces.
Updated: 24 Jul 2024 8:40 EDT
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689993000/dd55a5d4-3de1-4900-bfac-295672da22a9.jpg?itok=00xMCHaI)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689993000/dd55a5d4-3de1-4900-bfac-295672da22a9.jpg?itok=00xMCHaI)
LTIMindtree
PL
Hi @saripalliy16834594 For displaying validation message you can use ootb- containsSpace edit validate rule.
(or)
for removing the spaces using Edit Input, try the below Java code.
java.util.StringTokenizer st = new java.util.StringTokenizer(theValue, " ");
String resultString=new String();
boolean bHasSpace = false;
while(st.hasMoreTokens())
{
resultString=resultString+(String)st.nextToken();
bHasSpace = true;
}
if (bHasSpace == true)
theValue=resultString;
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
HCL
IN
@Vamsi Krishna I tried with Above code , while saving its thowing error like
"This record has 1 error(s) in 1 place(s) .
line: -6 This method must return a result of type boolean
Compile failed."
Accepted Solution
Updated: 9 Jan 2025 10:04 EST
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689993000/dd55a5d4-3de1-4900-bfac-295672da22a9.jpg?itok=00xMCHaI)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689993000/dd55a5d4-3de1-4900-bfac-295672da22a9.jpg?itok=00xMCHaI)
LTIMindtree
PL
above code is for Edit Input rule.
for Edit Validate try the below code and check.
theProperty.setValue(theValue.replaceAll("\\s", ""));
return true;
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
HCL
IN
@Vamsi Krishna thankyou its working but small query in Tax number field No special characters taken expect + - / \ it can takes integers , alphabets.(but no special characters like @#$%^&*()).....except + - \ / can you suggest a code using edit validate.