Click here to Skip to main content
15,918,668 members
Home / Discussions / C#
   

C#

 
AnswerRe: Operator Overloading Pin
Butter18525-Jan-09 7:02
Butter18525-Jan-09 7:02 
GeneralRe: Operator Overloading Pin
Wendelius25-Jan-09 7:22
mentorWendelius25-Jan-09 7:22 
GeneralRe: Operator Overloading Pin
Butter18525-Jan-09 8:26
Butter18525-Jan-09 8:26 
QuestionRe: Operator Overloading [modified] Pin
Butter18525-Jan-09 20:41
Butter18525-Jan-09 20:41 
AnswerRe: Operator Overloading Pin
Wendelius26-Jan-09 7:46
mentorWendelius26-Jan-09 7:46 
Questionc# windows datagridview [modified] Pin
s_aslam9825-Jan-09 5:53
s_aslam9825-Jan-09 5:53 
Questioninserting more format into one line in word using C# Pin
Lopy12325-Jan-09 4:32
Lopy12325-Jan-09 4:32 
QuestionRegular Expressions Pin
the_jat25-Jan-09 3:49
the_jat25-Jan-09 3:49 
Hi! everyone,

Regular Expression sometimes match empty strings, can someone tell me why it happens and what is the use of matching empty strings(why have the original designers made it that way)? Here are some examples:

In these examples, the "Pattern" is the Pattern used for matching and the "MatchWith" is the string that is evaluated. The "Count" is the number of hits, and finally "Occurrences" lists all of them. Following is the output of a console application.

Pattern: \d*
MatchWith: 34544
String: 34544,  Pattern: \d*,   Match: |TRUE|
M String: 34544,        Position: 0,    Count: 2,       S Length: 5
Occurences:
String: 34544,  Length: 5,      Position: 0,    Success: True
String: ,       Length: 0,      Position: 5,    Success: True
-------------------------------------------------------

The above example matches an empty string, why?
Pattern: \d*
MatchWith: dfgdr
String: dfgdr,  Pattern: \d*,   Match: |TRUE|
M String: ,     Position: 0,    Count: 6,       S Length: 5
Occurences:
String: ,       Length: 0,      Position: 0,    Success: True
String: ,       Length: 0,      Position: 1,    Success: True
String: ,       Length: 0,      Position: 2,    Success: True
String: ,       Length: 0,      Position: 3,    Success: True
String: ,       Length: 0,      Position: 4,    Success: True
String: ,       Length: 0,      Position: 5,    Success: True
-------------------------------------------------------

The above example matches 6 empty strings, more than the actual length of the input string, why?

Following are examples of Lookahead:
Pattern: (?=.*\d)
MatchWith: 44
String: 44,     Pattern: (?=.*\d),      Match: |TRUE|
M String: ,     Position: 0,    Count: 2,       S Length: 2
Occurences:
String: ,       Length: 0,      Position: 0,    Success: True
String: ,       Length: 0,      Position: 1,    Success: True
-------------------------------------------------------

Above: again an empty string.

Pattern: (?=.*\d)
MatchWith: dfg
String: dfg,    Pattern: (?=.*\d),      Match: |FALSE|
M String: ,     Position: 0,    Count: 0,       S Length: 3
Occurences:
-------------------------------------------------------

Above: same failed with strings as input: "FALSE"

Pattern: (?=.*\d)
MatchWith: fgd3
String: fgd3,   Pattern: (?=.*\d),      Match: |TRUE|
M String: ,     Position: 0,    Count: 4,       S Length: 4
Occurences:
String: ,       Length: 0,      Position: 0,    Success: True
String: ,       Length: 0,      Position: 1,    Success: True
String: ,       Length: 0,      Position: 2,    Success: True
String: ,       Length: 0,      Position: 3,    Success: True
-------------------------------------------------------

Above: same pattern, but now matches of empty string

Thats all
Thanks Smile | :)
AnswerRe: Regular Expressions Pin
Guffa25-Jan-09 5:13
Guffa25-Jan-09 5:13 
Questiondiff in need of method overloading * cons overloading Pin
Ali_10024-Jan-09 23:58
Ali_10024-Jan-09 23:58 
AnswerRe: diff in need of method overloading * cons overloading Pin
DaveyM6925-Jan-09 0:12
professionalDaveyM6925-Jan-09 0:12 
QuestionPreventing filedestruction after saving richtextbox contents at program end Pin
fracalifa24-Jan-09 23:31
fracalifa24-Jan-09 23:31 
AnswerRe: Preventing filedestruction after saving richtextbox contents at program end Pin
Wendelius25-Jan-09 0:05
mentorWendelius25-Jan-09 0:05 
GeneralRe: Preventing filedestruction after saving richtextbox contents at program end Pin
fracalifa25-Jan-09 0:26
fracalifa25-Jan-09 0:26 
GeneralRe: Preventing filedestruction after saving richtextbox contents at program end Pin
DaveyM6925-Jan-09 0:32
professionalDaveyM6925-Jan-09 0:32 
AnswerRe: Preventing filedestruction after saving richtextbox contents at program end Pin
fracalifa25-Jan-09 0:59
fracalifa25-Jan-09 0:59 
GeneralRe: Preventing filedestruction after saving richtextbox contents at program end Pin
Wendelius25-Jan-09 0:35
mentorWendelius25-Jan-09 0:35 
GeneralRe: Preventing filedestruction after saving richtextbox contents at program end Pin
fracalifa25-Jan-09 0:56
fracalifa25-Jan-09 0:56 
GeneralRe: Preventing filedestruction after saving richtextbox contents at program end Pin
Wendelius25-Jan-09 1:02
mentorWendelius25-Jan-09 1:02 
AnswerRe: Preventing filedestruction after saving richtextbox contents at program end Pin
DaveyM6925-Jan-09 0:07
professionalDaveyM6925-Jan-09 0:07 
QuestionData binding Pin
half-life24-Jan-09 22:42
half-life24-Jan-09 22:42 
AnswerRe: Data binding Pin
Wendelius25-Jan-09 0:03
mentorWendelius25-Jan-09 0:03 
GeneralRe: Data binding Pin
half-life25-Jan-09 0:40
half-life25-Jan-09 0:40 
GeneralRe: Data binding Pin
Wendelius25-Jan-09 0:51
mentorWendelius25-Jan-09 0:51 
GeneralRe: Data binding Pin
half-life25-Jan-09 1:20
half-life25-Jan-09 1:20 

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.