Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
QuestionGetting Index Of Delimiters After A String Pin
MadDashCoder11-Sep-16 17:11
MadDashCoder11-Sep-16 17:11 
AnswerRe: Getting Index Of Delimiters After A String Pin
BillWoodruff11-Sep-16 19:31
professionalBillWoodruff11-Sep-16 19:31 
GeneralRe: Getting Index Of Delimiters After A String Pin
MadDashCoder11-Sep-16 19:56
MadDashCoder11-Sep-16 19:56 
GeneralRe: Getting Index Of Delimiters After A String Pin
BillWoodruff12-Sep-16 4:50
professionalBillWoodruff12-Sep-16 4:50 
AnswerRe: Getting Index Of Delimiters After A String Pin
OriginalGriff11-Sep-16 23:26
mveOriginalGriff11-Sep-16 23:26 
GeneralRe: Getting Index Of Delimiters After A String Pin
BillWoodruff12-Sep-16 5:05
professionalBillWoodruff12-Sep-16 5:05 
GeneralRe: Getting Index Of Delimiters After A String Pin
OriginalGriff12-Sep-16 5:09
mveOriginalGriff12-Sep-16 5:09 
AnswerRe: Getting Index Of Delimiters After A String Pin
#realJSOP12-Sep-16 8:49
mve#realJSOP12-Sep-16 8:49 
You could write an extension method to get the string between the delimiters:
C#
public static string BetweenChars(this string text, char left, char right)
{
    string result = string.Empty;
    int leftPos = text.IndexOf(left, 0)+1;
    int rightPos = text.LastIndexOf(right);
    if (leftPos >= 0 && rightPos > leftPos)
    {
        result = text.Substring(leftPos, rightPos - leftPos);
    }
    return result;
}

Or one to just get the delimiter positions
C#
public static void DelimiterPos(this string text, char left, char right, out int leftPos, out int rightPos)
{
    string result = string.Empty;
    leftPos = text.IndexOf(left, 0);
    rightPos = text.LastIndexOf(right);
}
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

GeneralRe: Getting Index Of Delimiters After A String Pin
MadDashCoder13-Sep-16 8:02
MadDashCoder13-Sep-16 8:02 
Questioncompare two textboxes (string) - need help Pin
mar malaza11-Sep-16 1:04
mar malaza11-Sep-16 1:04 
GeneralRe: compare two textboxes (string) - need help Pin
harold aptroot11-Sep-16 1:41
harold aptroot11-Sep-16 1:41 
AnswerRe: compare two textboxes (string) - need help Pin
#realJSOP11-Sep-16 3:30
mve#realJSOP11-Sep-16 3:30 
AnswerRe: compare two textboxes (string) - need help Pin
V.11-Sep-16 21:10
professionalV.11-Sep-16 21:10 
QuestionHow is check the date of a valid dateEdit ? Pin
Member 245846710-Sep-16 23:42
Member 245846710-Sep-16 23:42 
AnswerRe: How is check the date of a valid dateEdit ? Pin
OriginalGriff11-Sep-16 0:03
mveOriginalGriff11-Sep-16 0:03 
AnswerRe: How is check the date of a valid dateEdit ? Pin
#realJSOP11-Sep-16 3:21
mve#realJSOP11-Sep-16 3:21 
QuestionGroup Sequance patterns with Linq Pin
Member 121069269-Sep-16 1:27
Member 121069269-Sep-16 1:27 
AnswerRe: Group Sequance patterns with Linq Pin
Richard Deeming9-Sep-16 2:02
mveRichard Deeming9-Sep-16 2:02 
GeneralRe: Group Sequance patterns with Linq Pin
Member 121069269-Sep-16 2:10
Member 121069269-Sep-16 2:10 
AnswerRe: Group Sequance patterns with Linq Pin
#realJSOP9-Sep-16 2:14
mve#realJSOP9-Sep-16 2:14 
GeneralRe: Group Sequance patterns with Linq Pin
Member 121069269-Sep-16 2:19
Member 121069269-Sep-16 2:19 
GeneralRe: Group Sequance patterns with Linq Pin
#realJSOP9-Sep-16 2:25
mve#realJSOP9-Sep-16 2:25 
GeneralRe: Group Sequance patterns with Linq Pin
Member 121069269-Sep-16 2:28
Member 121069269-Sep-16 2:28 
SuggestionRe: Group Sequance patterns with Linq Pin
Richard Deeming9-Sep-16 4:15
mveRichard Deeming9-Sep-16 4:15 
GeneralRe: Group Sequance patterns with Linq Pin
#realJSOP9-Sep-16 4:18
mve#realJSOP9-Sep-16 4:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.