Posts Tagged ‘replace’

How to replace one or more whitespace in vb.net

  1. Imports System.Text.RegularExpressions</p>
  2. Module Example
  3.    Public Sub Main()
  4.       Dim input As String = "This is   text with   far  too   much   " +
  5.                             "whitespace."
  6.       Dim pattern As String = "\s+"
  7.       Dim replacement As String = " "
  8.       Dim rgx As New Regex(pattern)
  9.       Dim result As String = rgx.Replace(input, replacement)
  10.       Console.WriteLine("Original String: {0}", input)
  11.       Console.WriteLine("Replacement String: {0}", result)
  12.    End Sub
  13. End Module

, , , ,

No Comments


How to replace all occurrences in javascript

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″

,

No Comments



SetPageWidth