Twine Version: 2.9.1
Harlowe 3.3.9
Folks, I have been using Twine for almost two months and learned my way around Harlowe programming pretty well, but, pattern searching is quite strange compared to other languages.
I have a list of items preceded with 1 to 3 digit numbers like:
- Hello
- Dude
- Weather
And I simply want to strip away the number and period. With any other language I would just use a regular expression pattern and replace it with null text.
This is what I had to do in Harlowe:
(set: _t to “233. This is a test”)
(set: _t2 to (trimmed: (p-start: digit), _t))
(set: _t2 to (trimmed: (p-start: digit), _t2))
(set: _t2 to (trimmed: (p-start: digit), _t2))
(set: _t to (trimmed: (p-start: “.”), _t2))
This returns: “This is a test.”
Instead of 4 lines of code, I should be able to do this in 1 line. The three duplicated commands will each trim one digit at the start of the text. So up to three digits are trimmed, then the fourth command removes the decimal.
Anyone have a better way to do this? I must be missing something.