...
Wiki Markup |
---|
{description}
{excerpt}Searches for a string specified by the {{search}} parameter, and replaces it with the string specified by the {{replaceWith}} parameter. The search string can be a literal, a regular expression, or a combination of both. Since the string can contain regular expressions, use a backslash to escape special characters. Special characters are {{[\^$.|?*+() |
...
Signature |
---|
C# | C# | {\}}}.
{excerpt}
{signature:C#}
public virtual int SearchAndReplace(System.String search, System.String replaceWith)
|
Signature |
---|
{signature}
{signature:vb.net | vb.net | }
Public Overridable Function SearchAndReplace(ByVal search As String, ByVal replaceWith As String) As Integer
|
...
The string to find and replace.
...
The replacement string.
Returns |
---|
The number of occurences that were found and replaced. |
Example |
---|
Code Block |
---|
| csharp | csharp |
title | C# |
---|
{signature}
{parameters}
{param:search}The string to find and replace.
{param}
{param:replaceWith}The replacement string.
{param}
{returns}The number of occurences that were found and replaced.
{returns}
{example}{code:csharp|title=C#}
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\myDoc.doc");
//--- Update a copyright
//--- Search for: (c) or the copyright symbol in ASCII, one or more whitespace characters,
//--- four digits, and then any number of characters followed by 'Inc.'
//--- Replace matches with '(c) 2008 SoftArtisans, Inc.'
doc.SearchAndReplace("(\(c\)|\xA9)\s+[0-9]{4}\s+SoftArtisans, Inc\.", "(c) 2008 SoftArtisans, Inc.");
Code Block |
---|
{code}
{code:vb.net
vb.net | title | |title=vb.net
}
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\myDoc.doc")
'--- Update a copyright
'--- Search for: (c) or the copyright symbol in ASCII, one ore more whitespace characters,
'--- four digits, and then any number of characters followed by 'Inc.'
'--- Replace matches with '(c) 2008 SoftArtisans, Inc.'
doc.SearchAndReplace("(\(c\)|\xA9)\s+[0-9]{4}\s+SoftArtisans, Inc\.", "(c) 2008 SoftArtisans, Inc.")
{code}
{example}