I had the challenge to group mobile devices into mobile phone or tablets. For example, for Apple devices this was quite easy because the model either contains iPhone or iPad. However, looking at the model of Samsung devices this looks different. Here some examples:
samsung GT-P5210
samsung SM-G25F
samsung SM-G920F
samsung SM-G900F
samsung GT-I9506
I directly thought I can use Regex pattern to tackle the grouping however, I did not find a way to have the possibility of having a dynamic list of patterns in case new models are released and I do not want to open the workflow and republish it every time when an update comes out.
So I thought I might be able to use a list outside of workflow which I can go in and edit and this list I read within the workflow.
To read the list is one thing the other thing is to build the pattern from that list. Again this seems not something I could do with the built in “pattern” components. That is why I choose the Code Script component. The code script component now reads the list builds the pattern and does the matching.
Here the Workflow:
Here the Script (Code) Component:
Here the code:
Here the input list:
And here the result:
And if I update the list:
The result be like this:
Find the demo attached.