Grooper 21.00.0082 is available as of 12-12-2023! Check the  Downloads Discussion  for the release notes and to get the latest version.
Grooper 23.1.0016 is available as of 03-15-2024! Check the  Downloads Discussion  for the release notes and to get the latest version.
Grooper 23.00.0042 is available as of 03-22-2024! Check the Downloads Discussion for the release notes and to get the latest version.

How to filter SPACES from results

kylesouzakylesouza Posts: 156 ✭✭✭
Ok, so I can't post a picture of this due to it being protected personally identifiable information, but I've got a situation where a tax ID is coming out as
# # # - # # - # # # #
and I need it to be
###-##-###
I could do it with some named groups in the regular expression, but thought it would be cleaner to just exclude spaces from the output. My first thought was to use the Trim function in Results Options, but it only addresses preceding and receding characters.  Is there a simple character filter to remove a specific character from output results?
Kyle Souza
Data Wizard
P&P Oil & Gas Solutions

Best Answer

  • GrooperGuruGrooperGuru Posts: 481 admin
    Answer ✓
    There are a few different ways you could address this. I'll do my best to describe each below. There are a few other ways, one of which you've already mentioned, but the ones I've listed here are probably more practical. There has also been some discussion in the dev area recently about some new functionality in an upcoming version that would give you the ability to perform all kinds of different manipulations of data returned from a data type.
    1. On the pattern you've written, go to the properties -> pre-processing options -> Ignore Control Characters. Choose to ignore spaces. Now, what this will do is treat the entire document as though it has no spaces. Which means you would have to change your pattern accordingly. Also note, that if you also have tab or vertical tab marking enabled, those are special characters that will still be present in the eyes of this pattern. So if you have a situation where you can anchor off a leading and trailing \t, you may be able to make this work in an acceptable manner.
    2. Leave your pattern as-is, and allow it to return the value with all the spaces still there. Then on the host Data Type, add a Subtraction extractor with a pattern that just finds a single space. The purpose of a subtraction extractor is to take all the results of the data type and remove something from each result that matches another pattern. Note, if you attempt to remove things that span across lines, you will likely run into errors, as this feature is not intended to perform complex removals. Really just intended for simple things like what you've described.
    Matt Harrison
    Product Manager
    mharrison@bisok.com

Answers

  • kylesouzakylesouza Posts: 156 ✭✭✭
    Awesome, thank you @GrooperGuru. I went with option 1 for four of the six formats and it is working great now.
    Kyle Souza
    Data Wizard
    P&P Oil & Gas Solutions
Sign In or Register to comment.