Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

stringlib::subsop

Substitution in a string

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

stringlib::subsop(string, index = replacement)

Description

stringlib::subsop removes one or more characters at a given position and inserts another substring at that position instead.

The char with index index in string (if index is an integer) or the range of chars (if index is a range of integers) is removed. Instead replacement is inserted at that position. The inserted string need not have the same length.

Examples

Example 1

Delete the first character:

stringlib::subsop("abcdeabcdeabcde", 1 = "")

The 2nd to 3rd character will be replaced by "xxx":

stringlib::subsop("abcdeabcdeabcde", 2..3 = "xxx")

Delete the characters 2 to 11:

stringlib::subsop("abcdeabcdeabcde", 2..11 = "")

Parameters

string

Non empty string

index

Integer or range of integers that determines the chars to be replaced

replacement

Any string to replace the given char or range

Return Values

Given string with the replacement

Was this topic helpful?