ASP.NET | Estrarre il contenuto di una stringa mediante pattern
L’esempio seguente mostra come poter estrarre da un testo il contenuto di una stringa delimitata mediante in marcatori “\[” e “\]” Dim Regex As New Regex(“\\\[.\*?\]”, RegexOptions.Singleline) Dim Matches As MatchCollection = Regex.Matches(“la stringa da estrapolare è \[questa\]”) For Each Match As
L’esempio seguente mostra come poter estrarre da un testo il contenuto di una stringa delimitata mediante in marcatori “[” e “]”
Dim Regex As New Regex(“\[.*?]”, RegexOptions.Singleline)
Dim Matches As MatchCollection = Regex.Matches(“la stringa da estrapolare è [questa]”)
For Each Match As Match In Matches
Response.Write(Match.Value.Replace(“[”, String.Empty).Replace(“]”, String.Empty) & “
”)
Next