Skip to content

Commit edfca93

Browse files
committed
Added String Replace article
1 parent 0b8a645 commit edfca93

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# String_Replace
2+
3+
`String_Replace` returns a new string in which all occurrences of a specified `oldValye` Unicode character or String in the `source` string are replaced with another specified `newValue` Unicode character or String.
4+
5+
```csharp
6+
String_Replace (
7+
@source NVARCHAR (MAX),
8+
@oldValue NVARCHAR (MAX),
9+
@newValue NVARCHAR (MAX)
10+
)
11+
RETURNS NVARCHAR (MAX)
12+
```
13+
14+
## Parameters
15+
16+
- **source**: The source string.
17+
- **oldValue**: The string to be replaced.
18+
- **newValue**: The string to replace all occurrences of oldValue.
19+
20+
## Returns
21+
22+
- A string that is equivalent to the `source` string except that all instances of `oldValue` are replaced with `newValue`.
23+
- If `oldValue` is not found in the current instance, the method returns the `source` string without any changes.
24+
25+
## Example
26+
27+
```csharp
28+
SELECT SQLNET::String_Replace('1 2 3 4 5 6 7 8 9', ' ', ',')
29+
SELECT SQLNET::String_Replace('This docment uses 3 other docments to docment the docmentation', 'docment', 'document')
30+
```
31+
32+
# String_Replace4k
33+
34+
It is equivalent to `String_Replace` except no NVARCHAR(MAX) parameters; it can be used when input data will never be over 4000 characters as this function offers better performance.
35+
36+
```csharp
37+
String_Replace4k (
38+
@source NVARCHAR (4000),
39+
@oldValue NVARCHAR (MAX),
40+
@newValue NVARCHAR (MAX)
41+
)
42+
RETURNS NVARCHAR (4000)
43+
```
44+
45+
## Example
46+
47+
```csharp
48+
SELECT SQLNET::String_Replace4k('1 2 3 4 5 6 7 8 9', ' ', ',')
49+
SELECT SQLNET::String_Replace4k('This docment uses 3 other docments to docment the docmentation', 'docment', 'document')
50+
```

docs2/pages/documentations/string/string.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
Represents text as a sequence of UTF-16 code units.
44

5-
65
| Name | Description | Example |
76
| :--- | :---------- | :------ |
87
| [String_Compare(strA, strB)](/string-compare) | Compares two specified String objects. | [Try it]()|
@@ -36,3 +35,4 @@ Represents text as a sequence of UTF-16 code units.
3635
| [String_PadRight(source, totalWidth, paddingChar)](/string-padright) | Returns a new string that left-aligns the characters in this instance by padding them on the right with a specified Unicode character, for a specified total length. | [Try it]()|
3736
| [String_Remove(source, startIndex)](/string-remove) | Returns a new string in which all the characters in the `source` string, beginning at a specified position are deleted till the end of the `source` string. | [Try it]()|
3837
| [String_RemoveNumOfChars(source, startIndex, count)](/string-remove-num-of-chars) | Returns a new string in which a specified number of characters in the `source` beginning at a specified position have been deleted. | [Try it]()|
38+
| [String_Replace(source, oldValue, newValue)](/string-remove) | Returns a new string in which all occurrences of a specified Unicode character or String in the current string are replaced with another specified Unicode character or String. | [Try it]()|

0 commit comments

Comments
 (0)