Active class in the main menu

Make it dynamically to add class="active" to li when that link is
selected, but I still have a tiny issue, I want to add it to pages that
contains some strings such as "portfolio-" but I can't use {if
$action|contains:"portfolio-"} instead of {if $action eq "portfolio-"}
it should be eq!what's the soloution!?