String Match using regular expressions – VB.net
| vb.net | | copy code | | ? |
| 1 | Import Imports System.Text.RegularExpressions |
| 2 | |
| 3 | 'regularExpression_Match -> regular expression pattern to macth |
| 4 | Dim regularExpression_Match As New Regex("(.*)REGULAR EXPRESSION MATCH PATTERN(.*)") |
| 5 | 'txtInput.txt -> Text to macth against regularExpression_Match pattern |
| 6 | Dim myMatch As Match = System.Text.RegularExpressions.Regex.Match(txtInput.Text, regularExpression_Match) |
| 7 | If myMatch.Success Then |
| 8 | 'Do Something |
| 9 | End If |
| vb.net | | copy code | | ? |
| 1 | If Regex.IsMatch( userInputString, "\d+(\.?\d+)" ) Then |
| 2 | ' perform some conversion and math operations here |
| 3 | End If |
String Replace using regular expressions - VB.net
| vb.net | | copy code | | ? |
| 01 | Try |
| 02 | 'regularExpression_Replace -> regular expression pattern to replace |
| 03 | Dim regularExpression_Replace As New Regex("(.*)REGULAR EXPRESSION REPLACE PATTERN(.*)") |
| 04 | 'txtInput.txt -> Text to macth and replace against |
| 05 | Dim txtReplacementPattern As String |
| 06 | txtReplacementPattern = "THIS WILL BE MY REPLACED TEXT" |
| 07 | 'txtReplacementPattern = "$ " |
| 08 | txtInput.Text = regularExpression_Replace.Replace(txtInput.Text, _ |
| 09 | txtReplacementPattern) |
| 10 | Catch ex As Exception |
| 11 | Mess |
Regular Expressions in ASP.NET
Posted: July 20th, 2009
Categories: VB.net
Tags: Regular expressions, string match, string replace, VB.net
Comments: No Comments.
Categories: VB.net
Tags: Regular expressions, string match, string replace, VB.net
Comments: No Comments.