I would like for a regexp that extracts the number from an arbitrary string. The string can have chars before or after the number, but we can assume there is only one segment of digits forming the number.
arbitrarystring123
→ 123
1234 arbitrary string
→ 1234
Arbi12345trary String!
→ 12345
I’ve googled around and quite a few places propose simply \d+
(e.g here) or a bit more complex /(\d+)/
(e-g here) (or are those really the same?).
Assuming the above regexp is corrent, I guess I just don’t know how to put it into TW. Here is an attempt, but the output is the full string1234
. And if I put in the more complex expression above, the output is nothing:
<$let reg="\d+">
{{{ [[string1234]regexp<reg>] }}}
</$let>
I’ve also tested removing \
and brackets, etc, but nope.
What do I misunderstand?
Thank you!