?valid=true&trans_id=ABC&mpi_status_code=200&acs_url=https://www.secpay.com&MD=123456&PaReq=abc
any one help me write an expression to get the values for acs_url and the MD using regular expressions
Cheers
?valid=true&trans_id=ABC&mpi_status_code=200&acs_url=https://www.secpay.com&MD=123456&PaReq=abc
any one help me write an expression to get the values for acs_url and the MD using regular expressions
Cheers
I would use:
acs_url=(.*?)&MD=(.*?)&
In group(1) and group(2) you will have searched values.
Key part is ?
to finish matching at next char (&
in this case)
If the parameters are optional and can appear anywhere in the query string, as is normally the case, then you need to use two separate regular expressions:
acs_url=([^&#]) MD=([^&#])
Both regexes have a capturing group to extract the parameter's value.
Though these regular expressions correctly get the values of these parameters, they don't URL-decode them. You'll have to expect things like %2E
instead of the .
in your acs_url
parameter. These regexes may be suitable if you're looking at web logs in a text editor. But if you're writing a script that will actually run on a web server, you should use a class or library designed for processing URL parameters.