I have a string and i want to detect the value next to the string . for eg:
string s="the #awb 58981140743 is the number";
The value next to #awb needs to be detected.I want the result string to be (after #awb) .
string output=58981140743;
Use below regex to solve your problem.
string s = "the #awb 58981140743 is the number";
string result = Regex.Replace(s, @"[^\d]", "");
If you wan't specific string after #awb then use below code
string s = "the #awb 58981140743 is the number";
Regex.Match(s, @"#awb\s*(\d+)").Groups[1].Value;
string s = "the #awb 58981140743 is the number";
if (s.IndexOf("#awb") >= 0)
{
var temp = s.Split(new string[] { "#awb" }, StringSplitOptions.None)[1];
}
this code snippet will give you the result.
string s="the #awb 58981140743 is the number";
var splittedValue= s.Split(new string[] { "#awb" }, StringSplitOptions.None)[1];
This is how simply you can split and show your value
Regex.Match(s, @"#awb\s*(\d+)").Groups[1].Value
- add a check to see if a match is.Success