Forum Discussion
Esa_Kuusisto_27
Nimbostratus
Nov 21, 2007Best way to get one part of the url to variable
Hi all
I have problem getting one part of the url to variable. I need example test variable and contents of the variable I can get from url. I always need the first part from the url betwee...
Nov 26, 2007
Regexps are bad if you absolutely don't need them. They are very resource intensive and in most cases, there are better alternatives. If you want to extract a field from a string separated by delimiters, you can use the iRule getfield command.
http://devcentral.f5.com/wiki/default.aspx/iRules/getfield.html
Click hereFor your example URI of "/sales/office" The following commmand would extract the field "sales".
set val [getfield [HTTP::uri] "/" 2]This command extracts the specified field from the URI which is delimited by slashes "/". The first field would be the value before the first delimeter. In the case of a URI, it will always be an empty string. The second delimiter would be the value "sales", the third "office" and so on...
Hope this helps...
-Joe
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
