regsubstr as a function will help
(
https://docs.puppetlabs.com/references/latest/function.html#regsubst),
or you can do it in the fact itself using Ruby's string substitution:
http://www.ruby-doc.org/core-2.1.3/String.html#method-i-sub
The idea with both is that you need the incoming variable, a regular
expression to do the match, and then a replacement. Having said that
however, there are many options available to do string manipulation
that might help, such as split (which will convert a string into an
array by splitting on a common delimiter).
If you are struggling with the solution, perhaps you can post your
code so far, an example of what the data looks like and what you want
it to look like. I'm sure someone can then provide an example and an
explanation.
ken.