Since I’ve remebered I’d been avoiding sed. I’ve had preferred more intense manual work to writing those magical phrases. But not any more! Since I’m still a student I’ve been given a project to write some converter, text 2 html. I have to cover b, i, img, p and a tags. Insanely amazing and ambitious task…
Among the other problems, I had an issue, to convert
{www.google.com} into <a href="www.google.com">www.google.com</a>
and
{google!|www.google.com} into <a href="www.google.com">google!</a>

Final solution with sed
with linux tools only. I’ve tried ordinal Bash, grep, awk, but a problem occurred when there were links in both styles in one line.
Eventually I started doing that with sed. It took me some time to learn some fancy switches and syntax, but after some time – I did it! I can absolutely recommend Tim Robbins’ tutorial about sed: http://docs.funtoo.org/wiki/Sed_by_Example,_Part_3, parts 1,2 and 3.
It’s late at night, there’s a mug with 2 sips of coffee left in front of me, music in my headphones and dim light in the room. Work for today is done. In the moments as this one – I feel so… student? It definitely means to feel alive!
Hey, I gotta go to work in a few hours! I’ll just tweet that post and I get lost
Recent Comments