Posts Tagged ‘replace’
How to replace one or more whitespace in vb.net
Posted by: admin in .NET, Regular Expression (NET) on September 1st, 2011
-
Imports System.Text.RegularExpressions</p>
-
Module Example
-
Public Sub Main()
-
Dim input As String = "This is text with far too much " +
-
"whitespace."
-
Dim pattern As String = "\s+"
-
Dim replacement As String = " "
-
Dim rgx As New Regex(pattern)
-
Dim result As String = rgx.Replace(input, replacement)
-
Console.WriteLine("Original String: {0}", input)
-
Console.WriteLine("Replacement String: {0}", result)
-
End Sub
-
End Module
How to replace all occurrences in javascript
Posted by: admin in Javascript on October 10th, 2009
To replace all occurrences in a string use the “g” modifier without double quote like this
var strvar = “one two one”;
strvar = strvar.replace(/one/g,”1″);
the output of the strvar would be “1 two 1″