Skip to content

Commit fb4cfac

Browse files
committed
Check Regex match for Success
1 parent 60d2ec3 commit fb4cfac

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

SharpPocketToolsGUI/frmMain.vb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Imports System.ComponentModel
1+
Imports System.ComponentModel
22
Imports System.IO
33
Imports System.Text.RegularExpressions
44

@@ -405,7 +405,7 @@ Public Class frmMain
405405
Return
406406
End If
407407
match = Regex.Match(line, "^ *[0-9]+") 'match the number at the start of the line
408-
If match.Value IsNot "" Then
408+
If match.Success Then
409409
matchMap.Add(match.Value.Trim(), lineIndex)
410410
Dim newLine = Regex.Replace(line, "^ *[0-9]+", lineIndex.ToString().PadLeft(5))
411411
newLines.Add(newLine)
@@ -424,15 +424,15 @@ Public Class frmMain
424424
'Parse lines again to find GOTO or GOSUB statements to replace the line numbers
425425
For Each line In newLines
426426
match = Regex.Match(line, "^ *[']") 'skip lines starting with comments
427-
If match.Value IsNot "" Then
427+
If match.Success Then
428428
changedLines &= line & vbCrLf
429429
Continue For
430430
End If
431431
'The line is not a comment, go ahead
432432

433433
'Find lines that contain GOTO, GOSUB or THEN
434434
match = Regex.Match(line, "(GOTO|GOSUB|THEN)", RegexOptions.IgnoreCase)
435-
If match.Value Is "" Then
435+
If Not match.Success Then
436436
changedLines &= line & vbCrLf
437437
Continue For
438438
End If
@@ -451,14 +451,14 @@ Public Class frmMain
451451
'The line contains GOTO, GOSUB or THEN, but with variable, label, or plain string insted of constant line number
452452

453453
match = Regex.Match(line, "(GOTO|GOSUB|THEN) *"".*""", RegexOptions.IgnoreCase)
454-
If match.Value IsNot "" Then
454+
If match.Success Then
455455
'The line contains GOTO, GOSUB or THEN with a label, it is safe to copy unchanged.
456456
changedLines &= line & vbCrLf
457457
Continue For
458458
End If
459459

460460
match = Regex.Match(line, "(GOTO|GOSUB|THEN) *.*\$", RegexOptions.IgnoreCase)
461-
If match.Value IsNot "" Then
461+
If match.Success Then
462462
'The line contains GOTO, GOSUB or THEN with a string variable ($), it is safe to copy unchanged.
463463
changedLines &= line & vbCrLf
464464
Continue For

0 commit comments

Comments
 (0)