Salve,
dovrei trovare il contenuto tra due delimitatori in VB.NET.
Ho utilizzato questo codice, ma non capisco come mai funziona in una stringa e non con il contenuto di un file prelevato:
codice:
Dim myFileStream As FileStream
Dim myStreamReader As StreamReader
Dim contenuto As String
' Apro il file
myFileStream = New FileStream("config.php", FileMode.Open, FileAccess.Read, FileShare.Read)
' Leggo(l) 'output con la classe stream reader
myStreamReader = New StreamReader(myFileStream)
contenuto = myStreamReader.ReadToEnd
' Match data between single quotes hesitantly.
Dim col As MatchCollection = Regex.Matches(contenuto, "These are the settings required to connect to your MySQL Database.(.+?)// ****** STATUS CHECKS SYSTEM ******")
txt.Text = contenuto
' Loop through Matches.
For Each m As Match In col
' Access first Group and its value.
Dim g As Group = m.Groups(1)
txt.Text = txt.Text & g.Value & vbCrLf
Next
il contenuto di config.php è:
codice:
[...]
// ****** MASTER DATABASE SETTINGS ******
// These are the settings required to connect to your MySQL Database.
$sqlhostname = '';
$sqlusername = '';
$sqlpassword = '';
$sqldb = '';
// ****** STATUS CHECKS SYSTEM ******
// This option will allow HoloCMS to perform full status checks. This,
// however, slows down your site A LOT. It is therefore disabled by
// default.
[...]
Il contenuto del file viene prelevato correttamente, dato che se lo inserisco in una textbox appare, ma così il codice mi dà un errore con il seguente testo:
codice:
analisi di "These are the settings required to connect to your MySQL Database.(.+?)// ****** STATUS CHECKS SYSTEM ******" - Quantificatore nidificato *. in corso...
Però come dicevo se contenuto lo setto con valore "These are the settings required to connect to your MySQL Database.PAROLA// ****** STATUS CHECKS SYSTEM ******" trova correttamente PAROLA..