Build a URL Parsing Method that Converts Links in Strings into HTML Link Tags

0
596

This coding exercise will test your knowledge of how to utilize regular expressions in order to dynamically convert strings in Ruby.

Summary

Build a method that takes in a string that contains a URL and converts it into an HTML friendly link tag.

Exercise File

Code File

Exercise Description

Given the following strings:

"Some content without a link."
"Content with a link that has a period after it https://devcamp.com."
"https://devcamp.com that starts at the beginning"

Write a program that returns strings with HTML link tags.

Sample Output

"Some content without a link."
"Content with a link that has a period after it <a href='https://devcamp.com' target='_blank'>https://devcamp.com</a>."
"<a href='https://devcamp.com' target='_blank'>https://devcamp.com</a> that starts at the beginning"

Real World Usage

This is a common skill when it comes to building view helper methods in Rails. This particular exercise will test your ability to work with regular expressions and perform dynamic substitutions in strings.

Solution

Can be found on the solutions branch on github.

LEAVE A REPLY

Please enter your comment!
Please enter your name here