0

Is there a wildcard character for the Value Mapper transformation in Pentaho Spoon? I've done some digging and only found wildcard solutions for uploading files and documents. I need to be able to map any and all potential values that contain a specific word yet I don't have a way of identifying all possible variations of the phrase that contains that word.

Example: Map website values to a category.

Value -> Mapped Category

facebook.com -> Facebook

m.facebook.com -> Facebook

google.com -> Google

google.ca -> Google

I'd prefer to use a wildcard character (let's call it % for example) so that one mapping captures all cases for a given category (e.g. %facebook% -> Facebook) in my Value Mapper. Another benefit is that the wildcard would correctly map any future site traffic value that comes along. (e.g. A hypothetical l.facebook.com would be correctly mapped if it ever entered my data)

I've tried various characters as wildcards and none have worked. + \ * %

Please and thank you!

Pat
  • 1
  • 1
  • 1

1 Answers1

1

You can use the step Replace in String with regular expressions to do this.

If you still need the original field, create a copy first using the Calculator step. Then you can put a number of mappings into the Replace step. They will run in sequence and if the regex matches, replace the contents of the field with your chosen mapping.

The performance may not be great, but it gives you the full flexibility of regexes. Do keep in mind this way gives you the first match. See my example for what can go wrong.

enter image description here

Cyrus
  • 2,135
  • 2
  • 11
  • 14