Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 5:19
sitebuilderLuc Pattyn10-Sep-10 5:19 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 5:35
professionalBassam Abdul-Baki10-Sep-10 5:35 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 5:49
sitebuilderLuc Pattyn10-Sep-10 5:49 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 5:55
professionalBassam Abdul-Baki10-Sep-10 5:55 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 6:00
sitebuilderLuc Pattyn10-Sep-10 6:00 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 6:07
professionalBassam Abdul-Baki10-Sep-10 6:07 
GeneralRe: Regular Expressions Pin
harold aptroot10-Sep-10 6:27
harold aptroot10-Sep-10 6:27 
GeneralRe: Regular Expressions Pin
AspDotNetDev10-Sep-10 6:19
protectorAspDotNetDev10-Sep-10 6:19 
Luc Pattyn wrote:
IndexOf is fine for short strings; it is also fine for long strings if you know the character is present. It is a waste if you need several of them and most of those return nothing.


Huh? You do know there are overloads for IndexOf that take the starting position to scan from, right? Scan for first character, then scan for the second character starting from the position that follows the first, then scan for the third character starting from the position that follows the second character, and so on. I figure that would be very clear code that would be very performant as well.
C#
// You'd need to add logic to test if any of the characters don't exist (i.e., if IndexOf returns -1).
int index = str.IndexOf(char3, str.IndexOf(char2, str.IndexOf(char1) + 1) + 1);


GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 6:34
professionalBassam Abdul-Baki10-Sep-10 6:34 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 6:40
sitebuilderLuc Pattyn10-Sep-10 6:40 
GeneralRe: Regular Expressions Pin
AspDotNetDev10-Sep-10 7:19
protectorAspDotNetDev10-Sep-10 7:19 
GeneralRe: Regular Expressions Pin
AspDotNetDev10-Sep-10 7:21
protectorAspDotNetDev10-Sep-10 7:21 
GeneralRe: Regular Expressions [modified] Pin
Luc Pattyn10-Sep-10 7:31
sitebuilderLuc Pattyn10-Sep-10 7:31 
GeneralRe: Regular Expressions Pin
AspDotNetDev10-Sep-10 8:14
protectorAspDotNetDev10-Sep-10 8:14 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 11:58
professionalBassam Abdul-Baki10-Sep-10 11:58 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 17:02
sitebuilderLuc Pattyn10-Sep-10 17:02 
GeneralRe: Regular Expressions Pin
PIEBALDconsult11-Sep-10 15:59
mvePIEBALDconsult11-Sep-10 15:59 
GeneralRe: Regular Expressions Pin
Luc Pattyn11-Sep-10 16:11
sitebuilderLuc Pattyn11-Sep-10 16:11 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 16:48
professionalBassam Abdul-Baki10-Sep-10 16:48 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 4:20
sitebuilderLuc Pattyn10-Sep-10 4:20 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:30
professionalBassam Abdul-Baki10-Sep-10 4:30 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 4:41
sitebuilderLuc Pattyn10-Sep-10 4:41 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 4:50
professionalBassam Abdul-Baki10-Sep-10 4:50 
GeneralRe: Regular Expressions Pin
Luc Pattyn10-Sep-10 4:54
sitebuilderLuc Pattyn10-Sep-10 4:54 
GeneralRe: Regular Expressions Pin
Bassam Abdul-Baki10-Sep-10 5:02
professionalBassam Abdul-Baki10-Sep-10 5:02 

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.