Managing Over Spaces in Softanza: Beyond Simplify, Trim, and RemoveSpaces
Managing spaces in strings is a common task in programming, especially when dealing with user input, text formatting, or data cleaning. The Softanza library introduces the concept of "over spaces", which goes beyond conventional functions like RemoveSapces(), Trim() and Simplify(). This article explores these concepts, their implementations, and the specific tools Softanza provides to handle them effectively.
by Mansour Ayouni · in the repository since 2024-12-15 · feature essay · area String

A scholar exploring the mysteries of "Over Spaces" within an ancient, mystical library setting.
Understanding Over Spaces
Spaces are the blank characters that separate words, sentences, or structural elements within a string. While necessary, they can become problematic when excessive or misplaced.
Over spaces refer to excessive sequences of spaces that disrupt readability or formatting, typically appearing as multiple consecutive spaces within or around a string.
Softanza offers a suite of methods to manage spaces, each targeting specific needs. Let's explore these tools in detail.
Finding Over Spaces
Softanza introduces two methods to locate over spaces:
1. Using FindOverSpaces()
This method returns the positions of all over spaces as a flat list of indices. For example:
load "stzlib.ring"
o1 = new stzString(" irum epsum elo n ")
? @@( o1.FindOverSpaces() )
#--> [ 2, 3, 15, 16, 17, 18, 23, 26, 27 ]illustration
Here, indices [2, 3] mark leading over spaces, [15, 16, 17, 18] identify internal redundant spaces, and [23, 26, 27] correspond to trailing over spaces.
2. Using FindOverSpacesZZ()
This variant groups consecutive over spaces into sections, providing a structured output for better readability:
o1 = new stzString(" irum epsum elo n ")
? @@( o1.FindOverSpacesZZ() )
#--> [ [ 2, 3 ], [ 15, 18 ], [ 23, 27 ] ]illustration
This output makes it easier to process each block of over spaces individually.
Removing Spaces and Over Spaces
Softanza provides multiple methods for removing spaces, each tailored to specific use cases:
1. Using RemoveSpaces()
This method removes all spaces from the string, leaving no whitespace behind.
o1 = new stzString(" irum epsum elo n ")
o1.RemoveSpaces()
? @@( o1.Content() )
#--> "irumepsumelon"run on 2026-10-08 20:44 at commit 4a184e6f0: kept its promise
2 . Using Trim()
It is ideal for applications requiring tightly packed text or data.
3. Using Simplify()
The Simplify() method trims the string and replaces consecutive spaces with a single space, providing a cleaned and standardized result.
o1 = new stzString(" irum epsum elo n ")
o1.Simplify()
? @@( o1.Content() )
#--> "irum epsum elo n"run on 2026-10-08 20:44 at commit 4a184e6f0: kept its promise
4. What's different with RemoveOverSpaces()?
This method targets redundant spaces but retains meaningful ones, including leading and trailing spaces.
o1 = new stzString(" irum epsum elo n ")
o1.RemoveOverSpaces()
? @@( o1.Content() )
#--> " irum epsum elo "illustration
Replacing Over Spaces
Softanza's ReplaceOverSpaces() method replaces sequences of over spaces with a custom character or string:
o1 = new stzString(" irum epsum elo n ")
o1.ReplaceOverSpaces(:With = "~")
? @@( o1.Content() )
#--> " ~~irum epsum ~~elo ~~"illustration
This functionality is especially helpful for visualizing or marking excessive whitespace for debugging or further processing.
Simplify, RemoveSpaces, Trim and RemoveOverSpaces: A Comparison
| Feature | Trim() | Simplify() | RemoveSpaces() | RemoveOverSpaces() |
|---|---|---|---|---|
| Trims spaces | Yes | Yes | No | No |
| Reduces inner spaces | No | Yes (to a single space) | No | Removes redundant spaces |
| Finds spaces | No | No | No | No |
| Replaces spaces | No | No | No | No |
| Use case | Cleaning leading and trailing spaces | Standardizing text for readability | Compacting text for data storage | Balancing cleanup with structure |
The Importance of Managing Over Spaces
Managing over spaces is about control and precision. While trim and simplify are sufficient for many general-use cases, specific scenarios demand a more nuanced approach:
- Preserving Alignment: Leading or trailing spaces may define alignment in formatted text.
- Semantic Spaces: Excess spaces within a string might carry meaning, such as in tabulated data.
- Debugging and Visualization: Identifying over spaces is useful when debugging or preparing text for machine learning or analysis.
Softanza empowers developers to not only clean up strings but also understand and handle over spaces with fine-grained methods.
Conclusion: A Framework for Intelligent String Management
Softanza's comprehensive string management tools provide precise control over spaces, from complete removal with RemoveSpaces() to selective cleanup with RemoveOverSpaces(), Trim() and Simplify(). These methods enable developers to handle whitespace effectively across varied scenarios, reinforcing Softanza's position as a robust library for modern programming in the Haro language.
Cite
Mansour Ayouni. "Managing Over Spaces in Softanza: Beyond Simplify, Trim, and RemoveSpaces". Softanza narrations, 2024. https://mayouni.github.io/stzsite/en/narrations/stzstring-overspaces-narration.html
Run in Haro's name on 2026-10-08 20:44 inside the library at commit 4a184e6f0, block after block in one process: 2 of 6 blocks kept their promise; the others are illustrations. The code of the articles is Haro code. Where an article was written before the language took its present name, the name was changed and nothing else. Genre, area and series read from the file's name, the year from its first commit: derived, until the article carries its own header. The file on GitHub(opens in a new tab)

