File Exchange

image thumbnail

Swap Spaces

version (1.53 KB) by Alexandra
replaces spaces with underscores and vice versa


Updated 06 Jul 2011

View Version History

View License

replaces spaces with underscores or underscores with spaces; useful for desciptions/titles and file names

Cite As

Alexandra (2021). Swap Spaces (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Michael Goldstein

Very helpful for basic adjustments to file- and title-names. Thank you!


It would be more useful, if the user can decide if the spaces are converted to underscores or the other way around. E.g. if I want a filename without spaces, a swapping does not create the wanted result in 50% of the cases.
STRREP is faster than REGEXPREP.

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!