Click here to Skip to main content
15,887,175 members
Home / Discussions / C#
   

C#

 
AnswerRe: A timer & a while function Pin
Skippums27-Nov-07 6:58
Skippums27-Nov-07 6:58 
GeneralRe: A timer & a while function Pin
danzar27-Nov-07 11:14
danzar27-Nov-07 11:14 
AnswerRe: A timer & a while function Pin
led mike27-Nov-07 7:41
led mike27-Nov-07 7:41 
GeneralRe: A timer & a while function Pin
danzar27-Nov-07 11:26
danzar27-Nov-07 11:26 
GeneralRe: A timer & a while function Pin
led mike27-Nov-07 11:41
led mike27-Nov-07 11:41 
QuestionRegular expressions Pin
hamidkhan27-Nov-07 6:21
hamidkhan27-Nov-07 6:21 
AnswerRe: Regular expressions Pin
Skippums27-Nov-07 6:53
Skippums27-Nov-07 6:53 
AnswerRe: Regular expressions Pin
TJoe27-Nov-07 8:41
TJoe27-Nov-07 8:41 
First off, this[^] page is a great reference.

As for you questions, the $ is described under the "Atomic Zero-Width Assertions" section as "Specifies that the match must occur at the end of the string, before \n at the end of the string, or at the end of the line". Whether it matches at the end of the string or before a newline is based on the RegexOptions[^]. MSDN decribes the Multiline option as "Changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.".

If you need to match a literal $ then you need to preceed it with a backslash (\) or include it in a character class (e.g. [$]).

Technically, (?.*$) is not valid. You may have meant (?:.*$), which is a non-capturing grouping construct (the (?Unsure | :~ ) part). See the "Grouping Constructs" from the link above. Basically, this tells the regex engine that you do not want to capture the characters matched by the .*$ part into a separate group. They will still be included in the overall match though.

For your second question, this is a form of recursion really. Hopefully, this break down will explain it:

(the | character indicates the current position of the regex engine)

1. |aababb
The (?<1>a) portion will match "a" from the input and save it in a group called "1".

2. a|ababb
The (?<1>\1b) portion is really (?<1>ab) at this point because group "1" has the value "a", so it will match "ab" from the input and overwrite the value in group "1" with "ab".

3. aab|abb
Since the (?<1>\1b) has the *, which means zero or more matches, then we perform this portion again. The (?<1>\1b) portion is really (?<1>abb) at this point because group "1" has the value "ab", so it will match "abb" from the input and overwrite the value in group "1" with "abb".

4. aababb|
We are at the end of our string so we are done. Now the full string matched would be "aababb". The value of the group "1" would be "abb", eventhough it previously held the values "a" and "ab".

If we had used <2> in the second construct, then step 1 would work the same, but step 2 and beyond would work like this:

2 (alt). a|ababb
The (?<2>\1b) portion is really (?<2>ab) at this point because group "1" has the value "a", so it will match "ab" from the input and save the value in a group called "2".

3 (alt). aab|abb
Since the (?<2>\1b) has the *, which means zero or more matches, then we perform this portion again. The (?<2>\1b) portion is really (?<2>ab) at this point because group "1" has the value "a", so it will match "ab" from the input and overwrite the value in group "2" with "ab".

4 (alt). aabab|b
At this point we can't match any more characters so we are done. Now the full string matched would be "aabab" (one less char than above). The value of the group "1" would be "a" and the value of the group "2" would be "ab".



Take care,
Tom

-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com

GeneralRe: Regular expressions Pin
Skippums27-Nov-07 11:09
Skippums27-Nov-07 11:09 
GeneralRe: Regular expressions Pin
TJoe27-Nov-07 12:33
TJoe27-Nov-07 12:33 
GeneralRe: Regular expressions Pin
hamidkhan8-Dec-07 5:22
hamidkhan8-Dec-07 5:22 
QuestionCombo Box.ValueMember Problem Pin
sajid.salim.khan27-Nov-07 6:00
sajid.salim.khan27-Nov-07 6:00 
AnswerRe: Combo Box.ValueMember Problem Pin
led mike27-Nov-07 6:13
led mike27-Nov-07 6:13 
AnswerRe: Combo Box.ValueMember Problem Pin
pmarfleet27-Nov-07 6:16
pmarfleet27-Nov-07 6:16 
GeneralRe: Combo Box.ValueMember Problem Pin
sajid.salim.khan27-Nov-07 6:24
sajid.salim.khan27-Nov-07 6:24 
QuestionVariables and Command Button Pin
Chip Lambert27-Nov-07 5:19
Chip Lambert27-Nov-07 5:19 
AnswerRe: Variables and Command Button Pin
darkelv27-Nov-07 5:25
darkelv27-Nov-07 5:25 
GeneralRe: Variables and Command Button Pin
Chip Lambert27-Nov-07 5:29
Chip Lambert27-Nov-07 5:29 
GeneralRe: Variables and Command Button Pin
Colin Angus Mackay27-Nov-07 5:30
Colin Angus Mackay27-Nov-07 5:30 
GeneralRe: Variables and Command Button Pin
darkelv27-Nov-07 5:33
darkelv27-Nov-07 5:33 
AnswerRe: Variables and Command Button Pin
szukuro27-Nov-07 5:26
szukuro27-Nov-07 5:26 
QuestionWindows form and filesystem watcher threading issue Pin
tsiv27-Nov-07 4:28
tsiv27-Nov-07 4:28 
AnswerRe: Windows form and filesystem watcher threading issue Pin
Vikram A Punathambekar27-Nov-07 4:41
Vikram A Punathambekar27-Nov-07 4:41 
GeneralRe: Windows form and filesystem watcher threading issue Pin
tsiv27-Nov-07 5:55
tsiv27-Nov-07 5:55 
GeneralRe: Windows form and filesystem watcher threading issue Pin
led mike27-Nov-07 6:02
led mike27-Nov-07 6: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.