regex

Extracting and manipulation numbers from a text string

Tagged:  •    •    •    •  

Some years ago I came across a interesting text manipulation puzzle, on a c++ site
I think. I was learning Ruby at the time so had fun with implimenting in Ruby,
I decided to redo it in gst -- just for fun.

The problem: you have a string of mixed Alpha and Numeric characters, jumbled up,

'098m03r9f80239802389f0m9KDKL3KLJDKLJm0983m890DMOm003  dlkfj33hljf4h3klhl00000002998'.

We need to extract all the numerics, sort them into numeric order, but print them with leading zeros retained. Its not as obvious as it seems BTW. :-)

Syndicate content

User login