Answered by:
only retrieving selected parts of the request.querystring

Question
-
User-114084758 posted
Hi all,
I have used request.querystring to retrieve the houseID but i only need the ID (381) how can i remove the rest of the unwanted querystring? e.g. EAL_PRICING_HOUSEID%25%25%2f.
the context of my query string is below
QueryString = {houseID=381EAL_PRICING_HOUSEID%25%25%2f}
Many thanks
Paul
Saturday, June 20, 2015 2:26 PM
Answers
-
User2103319870 posted
Muncher39
Hi all,
I have used request.querystring to retrieve the houseID but i only need the ID (381) how can i remove the rest of the unwanted querystring? e.g. EAL_PRICING_HOUSEID%25%25%2f.
the context of my query string is below
QueryString = {houseID=381EAL_PRICING_HOUSEID%25%25%2f}
Many thanks
Paul
You can use Regex to get only number from string like given below
//Your QUerystring value string querystring = "houseID=381EAL_PRICING_HOUSEID%25%25%2f"; //Get only the number from string string houseid = Regex.Match(querystring, @"\d+").Value;
Ensure that you have added below namespace prior to using above code
using System.Text.RegularExpressions;
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, June 20, 2015 3:13 PM
All replies
-
User2103319870 posted
Muncher39
Hi all,
I have used request.querystring to retrieve the houseID but i only need the ID (381) how can i remove the rest of the unwanted querystring? e.g. EAL_PRICING_HOUSEID%25%25%2f.
the context of my query string is below
QueryString = {houseID=381EAL_PRICING_HOUSEID%25%25%2f}
Many thanks
Paul
You can use Regex to get only number from string like given below
//Your QUerystring value string querystring = "houseID=381EAL_PRICING_HOUSEID%25%25%2f"; //Get only the number from string string houseid = Regex.Match(querystring, @"\d+").Value;
Ensure that you have added below namespace prior to using above code
using System.Text.RegularExpressions;
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, June 20, 2015 3:13 PM -
User-114084758 posted
Awesome job, Just what i need :)
can you explain how that regex is working please?
thanks man
Paul
Saturday, June 20, 2015 3:34 PM -
User2103319870 posted
can you explain how that regex is working please?The method which we used is Regex.Match, this method Searches an input string for a substring that matches a regular expression pattern and returns the first occurrence.
Here we have used the Regex pattern 'd' which represent the numbers from 0-9 and '+' represents one or more occurences. So as a result you will get the numbers.
Saturday, June 20, 2015 5:37 PM