Scripted fields for match(regex)

Unfortunately, scripted fields work only on values within each individual doc. So if a doc had 3 numeric fields you could use a scripted field to add them together, or average them, or find the min, max, etc. But not across all docs or a set of docs.
But you can also use some scripting within Visualizations in the Advanced JSON field, not sure how much it would help you as I don't know what you need to do with the value after.
Here's an example: