Question

Compare 2 tables when one of them is regex


Hi, I have one table with phone numbers and another with regex for possibles mobile/phone numbers. I'd like to extract which ones of the first ones are mobile and which ones are regular phones. is it possible with feature merger? Many thanks


6 replies

Badge

Is it possible to add an example? It will be better if you can share a sample of the data which you are working on.

Badge +3

You can use the string searcher, attribute creator, tester etc. to do that.

As you need to execute the regex on the attribute holding the numbers, so you cant use the feature merger for that.

Your requirement would use 2 string searchers.

Or one tester or one attributecreator with conditional attribute creation.

Hi, as example I have a list of numbers such as 609412859, 650451278, 917173737, 925425693, and the another list with regex like

^[8-9]{1}[0-9]{1,2}[0-9]{6,7}$ for phone

^[6-7]{1}[0-9]{2}[0-9]{6}$ for mobile

so I can define which ones of the first list are phone and which ones mobile

the list is huge, this is just an example.

many thanks

Userlevel 2
Badge +17

Hi, as example I have a list of numbers such as 609412859, 650451278, 917173737, 925425693, and the another list with regex like

^[8-9]{1}[0-9]{1,2}[0-9]{6,7}$ for phone

^[6-7]{1}[0-9]{2}[0-9]{6}$ for mobile

so I can define which ones of the first list are phone and which ones mobile

the list is huge, this is just an example.

many thanks

How many are there different regular expressions? Just two?

 

Userlevel 2
Badge +17

If you have only a few patterns (regular expressions)  and they are static (i.e. won't be changed for each run), I think that configuring a conditional value for all possible regular expressions would be an easier solution, than reading regular expressions from the second table at run-time. The conditional value setting looks like:

If @Value(number) Contains Regex ^[8-9]{1}[0-9]{1,2}[0-9]{6,7}$
    Then phone
Else if @Value(number) Contains Regex ^[6-7]{1}[0-9]{2}[0-9]{6}$
    Then mobile
Else unknown 

If you need to get regular expressions and corresponding phone type names from the second table anyway, a possible way is: unconditionally merge all the regular expressions and phone type names to every phone number feature as a list attribute with a FeatureMerger, explode the list with a ListExploder, then use a Tester to test every feature whether its phone number matches the regular expression. In terms of the performance, however, it might be better write a Python script.

Badge +3

phonelol.fmw

try this one

Reply