Click here to Skip to main content
15,899,313 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to write regular expression for this code? Pin
OriginalGriff15-Sep-11 8:26
mveOriginalGriff15-Sep-11 8:26 
You can't - your code is wrong, on a number of levels.
Firstly:
C#
if(!identier.StartsWith("L#")
   identifier.Replace(something,"");
Is incomplete - the if condition is never terminated (you need a ')' in there.

(Assuming you fix that) Secondly:
If identifier starts with "L#" then it won't start with "X#". So, your replace operation will be called by at least one of the first two if conditions, and then always by the third.

(Assuming you fix that) Thirdly:
Strings in .NET are immutable - they cannot be changed - so string.Replace does nothing at all to identifier, but instead generates a new string, which you then discard.

As a result, your entire code block as shown can be replaced by nothing, as it has no effect whatsoever on subsequent code! You don't need a regex for that!

Think again what you are trying to do, and perhaps explain to us what results you are expecting, becauae that is not going to give them to you. Laugh | :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

Manfred R. Bihy: "Looks as if OP is learning resistant."

GeneralRe: how to write regular expression for this code? Pin
PIEBALDconsult15-Sep-11 9:10
mvePIEBALDconsult15-Sep-11 9:10 
GeneralRe: how to write regular expression for this code? Pin
OriginalGriff15-Sep-11 9:15
mveOriginalGriff15-Sep-11 9:15 
GeneralRe: how to write regular expression for this code? Pin
BillWoodruff15-Sep-11 21:42
professionalBillWoodruff15-Sep-11 21:42 
GeneralRe: how to write regular expression for this code? Pin
BillWoodruff15-Sep-11 21:43
professionalBillWoodruff15-Sep-11 21:43 
GeneralRe: how to write regular expression for this code? Pin
SRKSHOME15-Sep-11 20:21
SRKSHOME15-Sep-11 20:21 
GeneralRe: how to write regular expression for this code? Pin
Pete O'Hanlon15-Sep-11 20:32
mvePete O'Hanlon15-Sep-11 20:32 
GeneralRe: how to write regular expression for this code? Pin
SRKSHOME15-Sep-11 21:03
SRKSHOME15-Sep-11 21:03 
AnswerRe: how to write regular expression for this code? Pin
Luc Pattyn15-Sep-11 10:41
sitebuilderLuc Pattyn15-Sep-11 10:41 
GeneralRe: how to write regular expression for this code? Pin
PIEBALDconsult15-Sep-11 14:44
mvePIEBALDconsult15-Sep-11 14:44 
AnswerRe: how to write regular expression for this code? Pin
Luc Pattyn15-Sep-11 14:47
sitebuilderLuc Pattyn15-Sep-11 14:47 
QuestionDifference Between _number and number Pin
eddieangel15-Sep-11 6:11
eddieangel15-Sep-11 6:11 
AnswerRe: Difference Between _number and number Pin
BillWoodruff15-Sep-11 7:08
professionalBillWoodruff15-Sep-11 7:08 
GeneralRe: Difference Between _number and number Pin
eddieangel15-Sep-11 7:10
eddieangel15-Sep-11 7:10 
GeneralRe: Difference Between _number and number Pin
BillWoodruff15-Sep-11 7:40
professionalBillWoodruff15-Sep-11 7:40 
GeneralRe: Difference Between _number and number Pin
eddieangel15-Sep-11 7:46
eddieangel15-Sep-11 7:46 
GeneralRe: Difference Between _number and number Pin
BillWoodruff15-Sep-11 7:58
professionalBillWoodruff15-Sep-11 7:58 
GeneralRe: Difference Between _number and number Pin
eddieangel15-Sep-11 8:00
eddieangel15-Sep-11 8:00 
QuestionDLL native win32 variables lifetime? Pin
skaboFer15-Sep-11 3:39
skaboFer15-Sep-11 3:39 
AnswerRe: DLL native win32 variables lifetime? Crosspost Pin
Richard MacCutchan15-Sep-11 4:19
mveRichard MacCutchan15-Sep-11 4:19 
GeneralRe: DLL native win32 variables lifetime? Pin
skaboFer15-Sep-11 4:39
skaboFer15-Sep-11 4:39 
GeneralRe: DLL native win32 variables lifetime? Pin
Richard MacCutchan15-Sep-11 5:46
mveRichard MacCutchan15-Sep-11 5:46 
GeneralRe: DLL native win32 variables lifetime? Pin
skaboFer15-Sep-11 5:54
skaboFer15-Sep-11 5:54 
AnswerRe: DLL native win32 variables lifetime? Pin
BobJanova16-Sep-11 3:52
BobJanova16-Sep-11 3:52 
GeneralRe: DLL native win32 variables lifetime? Pin
skaboFer16-Sep-11 4:45
skaboFer16-Sep-11 4:45 

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.