Forum Discussion
FICO
3 years agoCommunity Manager
Remove Spaces from a STRING
Hi,
I am using FICO DM to write a Rule. For this Rule I need match the Postal Code from one source to the postal code from another source. The issue I am facing is that once source has a blank space in the string and before I can match the postal codes I need to remove that space.
Example:
PostalCode1 is A1B2F5
PostalCode2 is A1B 2F5
My rule is -
compressString(input.request.postalCode1) = compressString(input.request.postalCode2)
But for some reason I do not seem to make it work. Is there something that I am missing?
3 Replies
- FICOCommunity Manager
You can use the replaceAll() method to remove the space from a string. For example, the statements in SRL could be something like below:
PostalCode2 is a string initially "A1B 2F5";
Postalcode1 = PostalCode2.replaceAll("\\s", "").
- FICOCommunity Manager
Thanks! It worked perfectly...sorry as I am very new to the language I have another question.
I see that the replaceAll works with spaces. Would you be able to sent me a list that I can use to remove characters as well (i.e. within the brackets)?
For Example if i need to remove Special Characters from the above (example Postal Code was "L7A ?1W#4 to "L7A1W4")?
Thanks!
- FICOCommunity Manager
You can use the substitute() method of RegularExpression class to replace any characters in a string. Please refer to the Blaze Advisor documentation for more details.
Related Content
Related Content
New FICO® Xpress Community Repository on GitHub: A Collaborative Space for Optimization and Analytical Projects
2 MIN READWe are pleased to announce the launch of the FICO® Xpress Community Projects and Examples repository on GitHub. This initiative aims to foster collaboration and knowledge sharing among users of the FI...Removing O(rows) in XPRSbtran and XPRSftran
XPRSbtran and XPRSftran takes a dense array as input, hence there will be at least one scan over the basis dimension. If you solve multiple times the the extra complexity becomes a bottleneck, since ...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread0Views0likes2Comments