I came up with (perhaps not exclusively, as was The Calculus!) this approch to counting the # of chars in a string.
This counts integers, for example:
The trick being /something(0-many in the set of !something)/as many as it finds..... ..so like, for letter A, <code> my $As = () = /A^A*/gmy $x = () = /\d\D*/g;
We dont need no stinking loops, hashes, etc..
Just an idear I had.. Probably some others had it to but I didn't find it in searches....
caveat- this may not work in dbg. If not, try it outside dbg and it should be OK.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to count the number of chars in a string
by choroba (Cardinal) on Jun 05, 2020 at 17:55 UTC | |
|
Re: How to count the number of chars in a string
by LanX (Saint) on Jun 05, 2020 at 17:36 UTC |