Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove Spaces (or other characters) from a String
#10
I often end up using custom approaches to this depending on the situation.
When your string is very long (>1MB) performance very much depends on how you build up the new string.
- You can walk over the input-string and per character decide if you add it to the result-string
- Per character to remove, you can search (instr) and replace in a loop
- You can use _memcopy to copy all parts between characters you want to remove
- Or if possible the best: Use the original string in your processing and skip characters not wanted. This prevents in memory copying.
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply


Messages In This Thread
RE: Remove Spaces (or other characters) from a String - by mdijkens - 12-30-2022, 12:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  STRING$ empowered with StringPatternFilling TempodiBasic 6 1,238 05-09-2025, 06:00 PM
Last Post: TempodiBasic
  Split String to Array Using Strtok (Attempt #2) SpriggsySpriggs 0 545 12-17-2024, 06:37 PM
Last Post: SpriggsySpriggs
  Remove Remarks for Programs Pete 17 2,992 10-27-2024, 02:22 PM
Last Post: Dimster
  Variable characters eoredson 7 1,524 10-21-2024, 02:55 AM
Last Post: eoredson
  PrintW - print a long string, breaking it at the last space or hyphen before col. 79 TDarcos 21 4,093 04-22-2024, 09:52 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)