Click here to Skip to main content
15,889,691 members
Home / Discussions / C#
   

C#

 
GeneralRe: Socket programming Pin
mohammadkaab9-Jan-13 10:29
mohammadkaab9-Jan-13 10:29 
AnswerRe: Socket programming Pin
Richard MacCutchan9-Jan-13 4:42
mveRichard MacCutchan9-Jan-13 4:42 
AnswerRe: Socket programming Pin
Pete O'Hanlon9-Jan-13 5:27
mvePete O'Hanlon9-Jan-13 5:27 
AnswerRe: Socket programming Pin
harold aptroot9-Jan-13 6:14
harold aptroot9-Jan-13 6:14 
AnswerRe: Socket programming Pin
Thomas Daniels9-Jan-13 6:47
mentorThomas Daniels9-Jan-13 6:47 
QuestionLooking for a specific regex Pin
Dennis Bork8-Jan-13 21:31
Dennis Bork8-Jan-13 21:31 
AnswerRe: Looking for a specific regex Pin
Pete O'Hanlon8-Jan-13 22:27
mvePete O'Hanlon8-Jan-13 22:27 
AnswerRe: Looking for a specific regex Pin
savbace8-Jan-13 23:49
savbace8-Jan-13 23:49 
Here is an example of solution using both Regex and string class methods. In Regex I use a group with "FileCode" name to get result.
As Pete said not all cases require using of Regex. And in this case I think would be better to use string methods (alternative variant).
C#
const string pattern = @"_(?<FileCode>([^_][a-zA-Z0-9])+)\.txt$";
const string text = @"Directory\Subdirectory\Subdir\Subsubdir\sub_sub_subv009\filename_with_lots_of_ABC123.txt";

var groupFileCode = Regex.Match(text, pattern);

Console.WriteLine(groupFileCode.Groups["FileCode"].Value);

// alternatively without regullar expressions
int lastUnderscoreIndex = text.LastIndexOf('_');
int lastPointIndex = text.LastIndexOf('.');

Console.WriteLine(text.Substring(lastUnderscoreIndex + 1, lastPointIndex - lastUnderscoreIndex - 1));

Regards, savbace

AnswerRe: Looking for a specific regex Pin
lmoelleb9-Jan-13 0:12
lmoelleb9-Jan-13 0:12 
GeneralRe: Looking for a specific regex Pin
Dennis Bork9-Jan-13 3:26
Dennis Bork9-Jan-13 3:26 
AnswerRe: Looking for a specific regex Pin
thewazz9-Jan-13 3:38
professionalthewazz9-Jan-13 3:38 
AnswerRe: Looking for a specific regex Pin
PIEBALDconsult9-Jan-13 3:42
mvePIEBALDconsult9-Jan-13 3:42 
QuestionOrder execution sequence Pin
vanikanc8-Jan-13 10:32
vanikanc8-Jan-13 10:32 
AnswerRe: Order execution sequence Pin
YENSIX8-Jan-13 11:17
YENSIX8-Jan-13 11:17 
GeneralRe: Order execution sequence Pin
vanikanc8-Jan-13 14:36
vanikanc8-Jan-13 14:36 
GeneralRe: Order execution sequence Pin
vanikanc9-Jan-13 5:24
vanikanc9-Jan-13 5:24 
GeneralRe: Order execution sequence Pin
Pete O'Hanlon9-Jan-13 5:28
mvePete O'Hanlon9-Jan-13 5:28 
GeneralRe: Order execution sequence Pin
vanikanc9-Jan-13 9:41
vanikanc9-Jan-13 9:41 
GeneralRe: Order execution sequence Pin
YENSIX10-Jan-13 10:56
YENSIX10-Jan-13 10:56 
GeneralRe: Order execution sequence Pin
vanikanc14-Jan-13 9:45
vanikanc14-Jan-13 9:45 
QuestionCalling Console project Pin
PozzaVecia8-Jan-13 9:08
PozzaVecia8-Jan-13 9:08 
AnswerRe: Calling Console project Pin
PIEBALDconsult8-Jan-13 9:17
mvePIEBALDconsult8-Jan-13 9:17 
GeneralRe: Calling Console project Pin
SledgeHammer018-Jan-13 9:31
SledgeHammer018-Jan-13 9:31 
GeneralRe: Calling Console project Pin
PIEBALDconsult8-Jan-13 11:05
mvePIEBALDconsult8-Jan-13 11:05 
AnswerRe: Calling Console project Pin
PozzaVecia8-Jan-13 9:23
PozzaVecia8-Jan-13 9:23 

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.