I need to pass a parameter (part of URL) in a request for example:
"S;4;163;1;O;rAghjgjU="
But this value is extracted as a regular expression like that:
"S%3B4%3B163%3B1%3BO%3BrAghjgjU%3D"
I want to use BeanShell to decode the URL.
JMeter provides __urldecode() function so if you use it like:
${__urldecode(S%3B4%3B163%3B1%3BO%3BrAghjgjU%3D)}
you'll get the required value.
If you still want to go for Beanshell, you can invoke URLDecoder.decode(); method like:
String decoded = URLDecoder.decode("S%3B4%3B163%3B1%3BO%3BrAghjgjU%3D", "UTF-8");
There is also __Beanshell() function which allows executing arbitrary Beanshell script, invoke it like:
${__BeanShell(URLDecoder.decode("S%3B4%3B163%3B1%3BO%3BrAghjgjU%3D"\, "UTF-8"),)}
See How to Use BeanShell: JMeter's Favorite Built-in Component for more information on Beanshell scripting in JMeter, in particular pay attention to how Java and JMeter API classes are invoked from within Beanshell scripts.