How to use strrep() In MATLAB

 

The strrep() function is used to find and replace substrings. strrep(string1, string2, string3) is used to replace all occurrences of the string ‘string2’ within string ‘string1’ with the string ‘string3’.

 

Syntax: 

strrep(string1, string2, string3)

Example:

Matlab




% MATLAB code for space removal in
% string using strrep( )
% Initializing a string
String = 'G e e k s f o r G e e k s';
 
% Replacing space with null using the
% strrep() function over the above string
New_String = strrep(String,' ','')


Output:

New_String = w3wiki

How to remove space in a string in MATLAB?

In this article, we are going to discuss how to remove space from a string in MATLAB with the help of isspace(), find(), strrep(), and regexprep() functions.

Similar Reads

Using isspace()

The isspace() function is used to identify elements that are ASCII white spaces. isspace(‘string’) is used to find the white spaces present in the specified ‘string’....

Using strrep()

...

Using regexprep()

...

Using deblank()

...

Using strtrim()

...

Using erase()

The regexprep() function is used to replace text using regular expressions....

Using relational operator

...