View source code
							
							
						
								Display the source code in std/array.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						std.array.replace  - multiple declarations
				Function replace
Replace occurrences of from with to in subject in a new array.
						
				E[] replace(E, R1, R2)
				(
				
				  E[] subject,
				
				  R1 from,
				
				  R2 to
				
				)
				
				if (isForwardRange!R1 && isForwardRange!R2 && (hasLength!R2 || isSomeString!R2) || is(Unqual!E : Unqual!R1));
						
					
				Parameters
| Name | Description | 
|---|---|
| subject | the array to scan | 
| from | the item to replace | 
| to | the item to replace all instances of fromwith | 
Returns
A new array without changing the contents of subject, or the original
        array if no match is found.
See Also
substitute for a lazy replace.
Example
writeln("Hello Wörld"Function replace
Replace occurrences of from with to in subject in a new array.
    changed counts how many replacements took place.
						
				E[] replace(E, R1, R2)
				(
				
				  E[] subject,
				
				  R1 from,
				
				  R2 to,
				
				  ref size_t changed
				
				)
				
				if (isForwardRange!R1 && isForwardRange!R2 && (hasLength!R2 || isSomeString!R2) || is(Unqual!E : Unqual!R1));
						
					
				Parameters
| Name | Description | 
|---|---|
| subject | the array to scan | 
| from | the item to replace | 
| to | the item to replace all instances of fromwith | 
| changed | the number of replacements | 
Returns
A new array without changing the contents of subject, or the original
        array if no match is found.
Example
size_t changed = 0;
writeln("Hello Wörld"Function replace
Replaces elements from array with indices ranging from from
    (inclusive) to to (exclusive) with the range stuff.
						
				T[] replace(T, Range)
				(
				
				  T[] subject,
				
				  size_t from,
				
				  size_t to,
				
				  Range stuff
				
				)
				
				if (isInputRange!Range && (is(ElementType!Range : T) || isSomeString!(T[]) && is(ElementType!Range : dchar)));
						
					
				Parameters
| Name | Description | 
|---|---|
| subject | the array to scan | 
| from | the starting index | 
| to | the ending index | 
| stuff | the items to replace in-between fromandto | 
Returns
A new array without changing the contents of subject.
See Also
substitute for a lazy replace.
Example
auto a = [ 1, 2, 3, 4 ];
auto b = aAuthors
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.