How about m{/(\w+)(?:$|;arg=)}? (WebPerl Regex Tester)
However, obviously there may be cases where the regex might not work. As you've only given two examples, that's not really enough to confirm. Please see Re: How to ask better questions using Test::More and sample data for how to write more test cases for regexen. Or, you might want to look into using a proper parser such as URI (Update: choroba just posted an example).
In reply to Re: matching substring in url
by haukex
in thread matching substring in url
by cioperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |