Get the Special Character from URL [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Url is like That:
http://localhost:620251/Default.aspx/?group=Bkgbdsconsumer & Retailmailinglist
Want the group value on cs page:
Bkgbdsconsumer & Retailmailinglist
I ma doing this:
string group= HttpUtility.UrlEncode(Request.QueryString["group"]);

EDIT:
Ok, as I thought, there is no space before and after & in your URL.
Also port number is too big 620251 (max is 65535 as I think).
// 'fixed' port number
string url = #"http://localhost:12345/Default.aspx/?group=Bkgbdsconsumer&Retailmailinglist";
Uri myUri = new Uri (url);
var groupValue = HttpUtility.ParseQueryString (myUri.Query)["group"];
string[] allKeysWithoutValue = HttpUtility.ParseQueryString (myUri.Query).GetValues (null);
Now allKeysWithoutValue is an array with one element Retailmailinglist.

Related

how can i get string between two commas? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a string like:
43965.96000,16933.986,404689.986,5814892.171,77.464,52.47585589,13.59670032,77.464,0.675,-0.223
I want to just keep the string which is bold in characters between commas. How can I do that?
To take your question literally, you could do write a method to split the string by comma and just take the element at the 5th index:
string ParseData(string data)
{
return data.Split(',')[5];
}
So you'll be able to do something like:
string data = "43965.96000,16933.986,404689.986,5814892.171,77.464,52.47585589,13.59670032,77.464,0.675,-0.223";
string result = ParseData(data); // Result = "52.47585589"

How to get the file name having more then one extension in c# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am having file name as below.
i need only sample.xml as result.
sample.xml.jued.783737377365474.da
Please help me on this. thanks in Advance
File name can have one extension only:
string path = "sample.xml.jued.783737377365474.da";
// ".da"
var ext = Path.GetExtension(path);
However, in case you have a origin.extension.[some data].da pattern, you can split the file name by . and take first two items:
// sample.xml
var origin = String.Join(".", Path
.GetFileName(path)
.Split(new char[] { '.' }, 3)
.Take(2));

How to get ths parts out of url via RegEx [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have two urls:
http://sp2013/sites/1234
and
http://sp2013/pwa/projectsites/projectdetails.aspx?projuid=1234-123-123-123456-123456
I want to get from the first url the last part (always a number)
1234
and from the second url also the last part (guid)
1234-123-123-123456-123456
How could i achieve this through RegEx or maybe with string operations in C#?
string s = "http://sp2013/sites/1234";
var firstURLlastPart = new Uri(s).Segments.Last();
string s = "http://sp2013/pwa/projectsites/projectdetails.aspx?projuid=1234-123-123-123456-123456";
var secondURLlastPart = s.Split('=').Last();
Just split at '/' and take the last chunk for the first case.
str.Split('/').Last()
Split at '=' and take last chunk for second case
str.Split('=').Last()
(?!\/|\=).[-0-9]+$
It's working for both. But it also accepts if in first example will be number in format like this:
12345-4568

Extract number between bracket and colon [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need a regular expression to extract number 513922 from this string.
Error detected (513922: settings can not be applied.), param d1=0.0, d2=0.0 in operation mode
If you insist on regular expression:
string source =
"Error detected (513922: settings can not be applied.), param d1=0.0, d2=0.0 in...";
// 513922
string result = Regex.Match(source, #"(?<=\()[0-9]+(?=:)").Value;
// if you want integer representation:
int number = int.Parse(result);

Convert a string as a MAC Address [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Convert a string into mac address as example 0000001 need to change as 00:00:01 In php i can get it by this $HexVal=rtrim(strtoupper(chunk_split($hexval, 2, ':')),':'); i need exactly same in C#.
I have the first 6 value as 00:01:AB and i got the last six value from a decimal number. If i input 1 then it needs to change as 00:00:01. so then i con-cat to get my full mac as 00:00:AB:00:00:01.
OK got it,,
var temp = Regex.Replace("000001", ".{2}", "$0:");
var tempo = temp.Remove(temp.Trim().Length - 1);//or
var tempo = temp.Trim(':');

Categories

Resources