Alter url aliases programmatically I have a pattern set up to create the URL aliases based on a field of type list text.

the field looks like this:

selection 1|selection 1

selection 2|selection 2

How can I alter the alias so it will show something like this:

www.example.com/1-was-selected rather than www.example.com/selection-1

UPDATE:
I'm using Pathauto for the patterns.
I would create a custom token and use that in my alias. I'm assuming you're using pathauto to create your aliases. This page gives a pretty good example of how to create your own token. Then you can select your token in the pathauto UI.

You can create the hook_tokens_info hook basically exactly as they've done, but replacing the "customs" with your real values. For your hook_tokens implementation, you should have access to the entity in the $data variable i.e., $data['node'] will have your node object if you're using this for nodes. From there you should be able to do something like $data['node']-&gt;field_your_list_field-&gt;getValue() to get the value of your field. Just be sure to return a $replacements array where the key is your custom_token and the value is the value to replace with, in your case this would be something like you-selected-value-X.