regexp split any number with spaces
Hi
I'm scratching my head around a regexp problem and I can't find any solution to a problem that seems simple.
I want to split any number with spaces.
123 > 1 2 3
54682 > 5 4 6 8 2
I've tried several things but without success.
Thanks for your help !
You could simply use "[0-9] " as your expression and use the substring outlet:
Thanks Jan ! Now I feel really stupid. I started with too complicated things...
well, it a Max specific "hack", because it offers the substring outlet. in plain regex it would be a little bit more work ;)
.{1} is a good choice if you have an unknown mix of numbers, letters and symbols as input.
Hi Metamax,
Your code seems to work only when there's at least a letter or a symbol inside. If it's only numbers, I need to bang it twice and the output put the last number first.
793 > 3 7 0 3
Is it the same for you ?
Hi Pismo, yes, my mistake. Just add [tosymbol] prior to the input.
Nice ! Thanks ! Now I understand better how regexp works. I've found the same code as yours before but I was struggling to make it work.
That's what I think each time I write a regex and when writing the next one I feel like starting all over. Sometimes I wonder what kind of person it was who came up with it :)
PS: The most impressive one I once came across was a rexex to determine prime numbers!!!
Haha it's like black magic to me :) The problem is that I don't use it much. So every time I need it I also have to start from scratch because I only know a specific trick (and most of the time I've forget it). But when it finally works I like the magic effect :)