Update field based on regex results

Hello!
I'm new to ElasticSearch, and i need to create a field based on a query result.
More specific, i need to make a query search on a field that contains only a specific substring, then i need to estract from this field a substring and write it into another field.
There is a right way to do this?

i've already created the query that return only the documents that contains the specific query filter, but I don't know how to extract the specific substring from the document field with regex.

Thanks!

The only way I can think to do this would be to use the update-by-query API https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-update-by-query.html