Click here to Skip to main content
15,890,282 members
Home / Discussions / C#
   

C#

 
GeneralRe: A computer name Pin
Skippums10-Jan-08 7:33
Skippums10-Jan-08 7:33 
GeneralRe: A computer name Pin
Strategic_Thinker10-Jan-08 9:44
Strategic_Thinker10-Jan-08 9:44 
AnswerRe: A computer name Pin
Skippums10-Jan-08 9:50
Skippums10-Jan-08 9:50 
GeneralRe: A computer name Pin
Dave Kreskowiak10-Jan-08 7:35
mveDave Kreskowiak10-Jan-08 7:35 
GeneralInverse regex matching Pin
WillemM10-Jan-08 7:17
WillemM10-Jan-08 7:17 
GeneralRe: Inverse regex matching Pin
Skippums10-Jan-08 7:23
Skippums10-Jan-08 7:23 
GeneralRe: Inverse regex matching Pin
WillemM11-Jan-08 2:53
WillemM11-Jan-08 2:53 
GeneralRe: Inverse regex matching Pin
Skippums11-Jan-08 4:36
Skippums11-Jan-08 4:36 
Here is how I would implement it, if I were going to do what you describe (where 'n' is the desired length of the result):
1. Build a directed graph of your regex with nodes==state and edges==allowed state transitions
2. Build a structure containing the number of steps that can be made from
   any one state to any other that is <= the length of your result (2d matrix of lists)
3. Randomly choose an acceptance state (named 'as') where your connectivity matrix
   indicates you can go from the start state to the final state in exactly n transitions.
4. Iterate through the following (initialize cur = startStateNode) until your string is found:
   a. Set 'n' to 'n-1'
   b. Out of all of the nodes reachable from 'cur' in one move,
      eliminate those that can not reach 'as' in 'n' moves
   c. Choose one of the resulting nodes in the collection found in (b)
Once you finish with this process, you will have a randomly generated string matching your regex. Note, however, that strings produced do NOT have equal probability of being chosen. For example, if your regex is, say "(Becky|a\w*)", then "Becky" will result half of the time, whereas words beginning with the letter "a" (this set is clearly much larger) would take the other half. Choosing one at random with equal probability would require you to find ALL matching strings of your given length first, then choosing one of those strings at random (or, you could use graph theory and weight each choice by the number of possible ways to arrive at the destination in the required number of moves). Whatever you decide, I hope you can see that this is clearly not a trivial computation, and it will require a significant (IMO) source of man-hours to code. Good luck,

Sounds like somebody's got a case of the Mondays

-Jeff

GeneralRe: Inverse regex matching Pin
WillemM11-Jan-08 22:21
WillemM11-Jan-08 22:21 
QuestionTaskDialog? Pin
kumar.bs10-Jan-08 6:10
kumar.bs10-Jan-08 6:10 
AnswerRe: TaskDialog? Pin
Scott Dorman10-Jan-08 7:21
professionalScott Dorman10-Jan-08 7:21 
QuestionIf statement not reading gridview row Pin
Member 439056910-Jan-08 6:08
Member 439056910-Jan-08 6:08 
GeneralRe: If statement not reading gridview row Pin
Skippums10-Jan-08 7:17
Skippums10-Jan-08 7:17 
GeneralRe: If statement not reading gridview row Pin
Member 439056910-Jan-08 7:25
Member 439056910-Jan-08 7:25 
GeneralRe: If statement not reading gridview row Pin
Skippums10-Jan-08 7:35
Skippums10-Jan-08 7:35 
GeneralRe: If statement not reading gridview row Pin
Member 439056910-Jan-08 8:14
Member 439056910-Jan-08 8:14 
GeneralRe: If statement not reading gridview row Pin
Skippums10-Jan-08 8:35
Skippums10-Jan-08 8:35 
GeneralRe: If statement not reading gridview row Pin
Member 439056910-Jan-08 8:48
Member 439056910-Jan-08 8:48 
QuestionHello' Who can give me a hand? Pin
Member 472830110-Jan-08 6:02
Member 472830110-Jan-08 6:02 
GeneralRe: Hello' Who can give me a hand? Pin
DaveyM6911-Jan-08 4:48
professionalDaveyM6911-Jan-08 4:48 
GeneralRe: Hello' Who can give me a hand? Pin
Member 472830111-Jan-08 5:06
Member 472830111-Jan-08 5:06 
QuestionPrintPreviewControl: Suppress pagecount message? Pin
W Balboos, GHB10-Jan-08 5:45
W Balboos, GHB10-Jan-08 5:45 
AnswerRe: PrintPreviewControl: Suppress pagecount message? Pin
m@u10-Jan-08 6:22
m@u10-Jan-08 6:22 
GeneralRe: PrintPreviewControl: Suppress pagecount message? Pin
W Balboos, GHB10-Jan-08 7:56
W Balboos, GHB10-Jan-08 7:56 
GeneralList<int> Serialization Format</int> Pin
justwantcode10-Jan-08 5:14
justwantcode10-Jan-08 5:14 

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.