On Fri, 27 Sep 2024 11:52:04 +0000, Bob Martin wrote:
On 27 Sep 2024 at 11:10:37, The Natural Philosopher
<tnp@invalid.invalid> wrote:
On 27/09/2024 11:32, Kerr-Mudd, John wrote:
On Thu, 26 Sep 2024 20:51:25 -0000 (UTC) Lawrence D'OliveiroNOBODY needs REGEX!
<ldo@nz.invalid> wrote:
On Thu, 26 Sep 2024 16:18:01 GMT, Charlie Gibbs wrote:
One of the favourite functions in my library pulls the next token
from a delimited string, but as opposed to strtok() it does it
non-destructively and can handle empty strings.
Use a high-level language which has all this and more:
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
Output:
the quick brown fox
In Python, strings are objects, and that applies to string
expressions (including string literals) as well.
You need Rexx
He said Rexx; very superior language, written by a Brit at IBM Hursley
45 years ago,
Was, maybe still is, the default language on IBM mainframes.
https://sourceforge.net/projects/oorexx/files/
And for the original non O-O version:
https://sourceforge.net/projects/regina-rexx/
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
I was too lazy to dig into my rusty brain to code the equivalent inseparator
Rexx,
I was hoping someone here would do it!
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
OK,OK. Cribbed & hacked from a stackoverflow answer: https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
myline="the,quick,brown,fox"
do i = 1 by 1 while myline <> ''
parse var myline w.i ',' myline
end w.0 = i-1
do i = 1 to w.0
say w.i
end
Hmm, must be a shorter way without the bother of setting up the stem
array.
On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:
I was too lazy to dig into my rusty brain to code the equivalent in
Rexx,
I was hoping someone here would do it!
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
OK,OK. Cribbed & hacked from a stackoverflow answer: https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-separator
myline="the,quick,brown,fox"
do i = 1 by 1 while myline <> ''
parse var myline w.i ',' myline
end w.0 = i-1
do i = 1 to w.0
say w.i
end
Hmm, must be a shorter way without the bother of setting up the stem
array.
If you use space as a delimiter, which I would argue is more natural:
------------------------------------------
myline="the quick brown fox"
do i = 1 to words(myline)
say word(myline, i)
end
------------------------------------------
On 28 Sep 2024 09:41:59 GMT
Bob Eager <news0009@eager.cx> wrote:
On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:
I was too lazy to dig into my rusty brain to code the equivalent inseparator
Rexx,
I was hoping someone here would do it!
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
OK,OK. Cribbed & hacked from a stackoverflow answer:
https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
myline="the,quick,brown,fox"
do i = 1 by 1 while myline <> ''
parse var myline w.i ',' myline
end w.0 = i-1
do i = 1 to w.0
say w.i
end
Hmm, must be a shorter way without the bother of setting up the stem
array.
If you use space as a delimiter, which I would argue is more natural:
------------------------------------------
myline="the quick brown fox"
do i = 1 to words(myline)
say word(myline, i)
end
------------------------------------------
Thanks; It's been yea^w decades since I used Rexx. And even then not extensively. But Rexx has "Parse" which few(no?) other languages have.
Thanks; It's been yea^w decades since I used Rexx. And even then not extensively. But Rexx has "Parse" which few(no?) other languages have.Hmm, must be a shorter way without the bother of setting up the stem
array.
If you use space as a delimiter, which I would argue is more natural:
------------------------------------------
myline="the quick brown fox"
do i = 1 to words(myline)
say word(myline, i)
end ------------------------------------------
Kerr-Mudd, John wrote:
On 28 Sep 2024 09:41:59 GMT Bob Eager <news0009@eager.cx> wrote:What does "parse" do?
On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:Thanks; It's been yea^w decades since I used Rexx. And even then not
I was too lazy to dig into my rusty brain to code the equivalent inseparator
Rexx,
I was hoping someone here would do it!
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
OK,OK. Cribbed & hacked from a stackoverflow answer:
https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
myline="the,quick,brown,fox"
do i = 1 by 1 while myline <> ''
parse var myline w.i ',' myline
end w.0 = i-1
do i = 1 to w.0
say w.i
end
Hmm, must be a shorter way without the bother of setting up the stem
array.
If you use space as a delimiter, which I would argue is more natural:
------------------------------------------
myline="the quick brown fox"
do i = 1 to words(myline)
say word(myline, i)
end ------------------------------------------
extensively. But Rexx has "Parse" which few(no?) other languages have.
I just had a look at some REXX documentation but it was not particularly helpful, it looked to me to be something which a couple of FORTRAN 77 function calls would have handled perfectly adequately.
On Sun, 29 Sep 2024 11:23:18 +0200, R Daneel Olivaw wrote:
Kerr-Mudd, John wrote:
On 28 Sep 2024 09:41:59 GMT Bob Eager <news0009@eager.cx> wrote:What does "parse" do?
On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:Thanks; It's been yea^w decades since I used Rexx. And even then not
I was too lazy to dig into my rusty brain to code the equivalent inseparator
Rexx,
I was hoping someone here would do it!
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
OK,OK. Cribbed & hacked from a stackoverflow answer:
https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
myline="the,quick,brown,fox"
do i = 1 by 1 while myline <> ''
parse var myline w.i ',' myline
end w.0 = i-1
do i = 1 to w.0
say w.i
end
Hmm, must be a shorter way without the bother of setting up the stem >>>>> array.
If you use space as a delimiter, which I would argue is more natural:
------------------------------------------
myline="the quick brown fox"
do i = 1 to words(myline)
say word(myline, i)
end ------------------------------------------
extensively. But Rexx has "Parse" which few(no?) other languages have.
I just had a look at some REXX documentation but it was not particularly
helpful, it looked to me to be something which a couple of FORTRAN 77
function calls would have handled perfectly adequately.
It essentially splits a string into substrings, using specified
delimiters. The source string may be from a variety of places (variable, argument array, input line, stack) and there are some weird special cases such as getting the version number.
Essentially, you specify a template and it splits the string in accordance with that. For example:
parse var s1 "," s2 "-" s3
Kerr-Mudd, John wrote:
On 28 Sep 2024 09:41:59 GMT
Bob Eager <news0009@eager.cx> wrote:
On Sat, 28 Sep 2024 09:33:23 +0100, Kerr-Mudd, John wrote:
I was too lazy to dig into my rusty brain to code the equivalent inseparator
Rexx,
I was hoping someone here would do it!
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
OK,OK. Cribbed & hacked from a stackoverflow answer:
https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-
myline="the,quick,brown,fox"
do i = 1 by 1 while myline <> ''
parse var myline w.i ',' myline
end w.0 = i-1
do i = 1 to w.0
say w.i
end
Hmm, must be a shorter way without the bother of setting up the stem
array.
If you use space as a delimiter, which I would argue is more natural:
------------------------------------------
myline="the quick brown fox"
do i = 1 to words(myline)
say word(myline, i)
end
------------------------------------------
Thanks; It's been yea^w decades since I used Rexx. And even then not
extensively. But Rexx has "Parse" which few(no?) other languages have.
What does "parse" do?
I just had a look at some REXX documentation but it was not particularly helpful, it looked to me to be something which a couple of FORTRAN 77 function calls would have handled perfectly adequately.
But Rexx has "Parse" which few(no?) other languages have.
On 27 Sep 2024 14:17:38 GMT
Bob Eager <news0009@eager.cx> wrote:
On Fri, 27 Sep 2024 11:52:04 +0000, Bob Martin wrote:
On 27 Sep 2024 at 11:10:37, The Natural Philosopher
<tnp@invalid.invalid> wrote:
On 27/09/2024 11:32, Kerr-Mudd, John wrote:
On Thu, 26 Sep 2024 20:51:25 -0000 (UTC) Lawrence D'OliveiroNOBODY needs REGEX!
<ldo@nz.invalid> wrote:
On Thu, 26 Sep 2024 16:18:01 GMT, Charlie Gibbs wrote:
One of the favourite functions in my library pulls the next token >>>>>>> from a delimited string, but as opposed to strtok() it does it
non-destructively and can handle empty strings.
Use a high-level language which has all this and more:
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
Output:
the quick brown fox
In Python, strings are objects, and that applies to string
expressions (including string literals) as well.
You need Rexx
He said Rexx; very superior language, written by a Brit at IBM Hursley
45 years ago,
Was, maybe still is, the default language on IBM mainframes.
https://sourceforge.net/projects/oorexx/files/
And for the original non O-O version:
https://sourceforge.net/projects/regina-rexx/
I was too lazy to dig into my rusty brain to code the equivalent in Rexx,
I was hoping someone here would do it!
for item in "the,quick,brown,fox".split(",") :
print(item)
#end for
OK,OK. Cribbed & hacked from a stackoverflow answer: https://stackoverflow.com/questions/15437494/rexx-parse-a-csv-line-separator
myline="the,quick,brown,fox"
do i = 1 by 1 while myline <> ''
parse var myline w.i ',' myline
end
w.0 = i-1
do i = 1 to w.0
say w.i
end
Hmm, must be a shorter way without the bother of setting up the stem
array.
--xpost to comp.lang.rexx, if it still exists
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 14:51:21 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
10 files (18,532K bytes) |
| Messages: | 265,533 |