# regular expressions and number orientated strings

Page 1 of 1

## 0 Replies - 213 Views - Last Post: 10 November 2014 - 10:03 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=357689&amp;s=7f7f1c54b526ab9ea7de6ada60195210&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 wizrd3d

• New D.I.C Head

Reputation: 0
• Posts: 2
• Joined: 03-October 14

# regular expressions and number orientated strings

Posted 10 November 2014 - 10:03 AM

```Dim Combinations As New List(Of String)
For x1 As Integer = 1 To 70
For x2 As Integer = x1 + 1 To 70
For x3 As Integer = x2 + 1 To 70
For x4 As Integer = x3 + 1 To 70

Dim numbers() As String = {x1.ToString, x2.ToString, x3.ToString, x4.ToString }
Application.DoEvents()
Dim Regex As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("\d+")

Dim Add As Boolean = True
‘checking if there are the same numbers in string
Regex.matches(str,numbers(x4) & numbers(x5 +1))
If m.count > Then Add = False

‘if the add is true add number sequences to the list
If Add Then Combinations.Add(numbers(x1) & "," & numbers(x2) & "," & numbers(x3) & "," & numbers(x4)
Next
Next
Next
Next

```

I've been learning more about regular expressions and they as complicated as they're they are also easy to use but I came across a stumbling block when it came to the code above. Whn I fun the normal combination string of code I get results like 1,2,3,6
1,2,3,7
1,2,3,8
That is all displayed in a listbox so I have been trying to remove all sequences with consecutive numbers and leave only those with either the same numbers or different numbers.basically I want to illiminate all sequences with consecutive numbers e.g 1,2,3,6 from populating my listbox,I learned about using regex and it was all goin well till I had to execute the solution below I just seemed to get errors,as you can see I use the true and false statements so if these restrictions are found to be true that all sequences regardles of the position of the numbers in the squence e.g 1,2,3,6 or 1,2,6,3 they not appear on the list.I need guidence as to how I can possibly archieve this goal

This post has been edited by AdamSpeight2008: 10 November 2014 - 10:16 AM
Reason for edit:: Poster put code tags around each line of code like a dumpty

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }