Files
EgtDOORCreator/RegexFunction.vb
T
Nicola Pievani 0bc8e470b9 EgtDOORCreator 1.8j1 :
- creazione di assemblati
2017-11-21 16:07:47 +00:00

82 lines
3.2 KiB
VB.net

Imports System.Text.RegularExpressions
Module RegexFunction
' restituisce vero se trova il capitoletto [Graphic parameters]
Friend Function IsGraphicParametersTitle(sLine As String) As Boolean
If Regex.Match(sLine, "\s*--\s*(\[Graphic parameters\])\s*$").Groups(1).Value = "[Graphic parameters]" Then
Return True
End If
Return False
End Function
' restituisce quello che segue l'uguale assegnata una parola chiave tra i due trattini e 'uguale
Friend Function ParamLine(sLine As String, sKey As String) As String
Return Regex.Match(sLine, "\s*--\s*(" & sKey & ")\s*=\s*(.*)\s*$").Groups(2).Value
End Function
' verifico che il messaggio da stampare a video non abbia la forma "Msg1000"
Friend Function EgtMsgNotFound(sMsg As String) As Boolean
If Regex.Match(sMsg, "\s*(Msg)\s*(.*)\s*$").Groups(1).Value = "Msg" Then
Return True
Else
Return False
End If
End Function
' restituisca la stringa di commento
Friend Function SearchComments(sLine As String) As Boolean
If String.IsNullOrEmpty(Regex.Match(sLine, "\s*#\s*(.*?\b)\s*$").Groups(1).Value) Then
Return False
Else
Return True
End If
End Function
' restituisce la stringa che precede i commenti
Friend Function SearchStringBeforeComments(sLine As String) As String
Return Regex.Match(sLine, "\s*(.*?)\s*#.*$").Groups(1).Value
End Function
' restituisce quello che segue l'uguale assegnata la parola chiave Err
Friend Function ErrDraw(sLine As String) As Integer
Dim sErrMsg As String = Regex.Match(sLine, "\s*(Err)\s*=\s*(.*?\b)\s*$").Groups(2).Value
' se il valore è numerico allora lo restituisco
If IsNumeric(sErrMsg) Then
Return CInt(sErrMsg)
Else
' altrimenti restituisco il valore zero (non errore)
Return 0
End If
End Function
Friend Function ParamExpression(sLine As String) As String
Return Regex.Match(sLine, " \s*\(*\s*(.*?\b)\s*\).*$").Groups(1).Value
End Function
' Cerca la stringa con 3 trattini
Friend Function Search3Score(sLine As String) As Boolean
If Regex.Match(FindComments(sLine), "\s*(---).*$").Groups(1).Value = "---" Then Return True
Return False
End Function
' Cerca la stringa con 3 puntini
Friend Function Search3Dots(sLine As String) As Boolean
If Regex.Match(FindComments(sLine), "\s*(...).*$").Groups(1).Value = "..." Then Return True
Return False
End Function
' restituisce il valore dopo i due punti
Friend Function SearchKeyValue(sLine As String, sKey As String) As String
Dim x = Regex.Match(FindComments(sLine), "\s*-*\s*" & sKey & "\s*:\s*(.*?\b)\s*$").Groups(1).Value
Return Regex.Match(FindComments(sLine), "\s*-*\s*" & sKey & "\s*:\s*(.*?\b)\s*$").Groups(1).Value
End Function
' cerca il nome che precede i due punti
Friend Function SearchKey(sLine As String, sKey As String) As Boolean
Dim x = FindComments(sLine)
If Not Regex.Match(FindComments(sLine), "\s*(" & sKey & ")\s*:.*$").Groups(1).Value = sKey Then Return False
Return True
End Function
End Module