Forum > Beginners

Split a string in words

(1/3) > >>

I have a string composed of four words of arbitrary length, separated by ";" character.

Not a single word will be empty, so checking is not necessary.

I came with two methods, compiling the program with any of it activated, I get the same code size.

Any other method?

Long time ago I was using this function:

But maybe there are built-in function about parsing words like as:

Thank you for the links, I prefer not to use dynamic allocation...


--- Quote from: funlw65 on January 05, 2022, 05:33:20 am ---Thank you for the links, I prefer not to use dynamic allocation...

--- End quote ---

Then use TStringList and set its Delimiter and DelimitedText properties.

Another possibility:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Uses StrUtils; var  i: integer;  Begin  { ... }  for i := 1 to WordCount(pigeon_record, [';']) do  begin    WriteLn(ExtractWord(i, pigeon_record, [';']));  end;End.


[0] Message Index

[#] Next page

Go to full version