Use the MODX filterPathSegment method to filter a string value into valid URL syntax. Useful for HTML attribute values as well.
<?php
$options = $modx->getOption('options', $scriptProperties, $modx->getOption('friendly_alias_restrict_chars_pattern'), true);
return $modx->filterPathSegment($input, array('friendly_alias_restrict_chars_pattern' => $options));