Thursday, March 19, 2009

Regex Expresions

Remove Control Chars

RegularExpressions.Regex.Replace(value, "[^\t -~]", "")

Remove Non Alpha Chars

RegularExpressions.Regex.Replace(value, "[^A-Za-z0-9]", "")


Using xPath with Vb.NET

Dim fn As String = "c:\joy\linkage.xml"
Dim
doc As XPathDocument = New XPathDocument(fn)
Dim
nav As XPathNavigator = doc.CreateNavigator
Dim
expr As XPathExpression = nav.Compile("set:distinct(/DocumentElement/tLinkage/link_key_2)")
Dim
nt As Xml.XmlNameTable = doc.CreateNavigator.NameTable
expr.SetContext(New ExsltContext(nt))
Dim
ni As XPathNodeIterator = nav.Select(expr)
For
Each i In ni
Console.WriteLine(i.value)
Next