[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I convert '[download file="file.pdf"]File[/download]' into something else?

Posted on 2009-05-07
2
Medium Priority
?
252 Views
Last Modified: 2012-05-06
I'm making a wordpress plugin and want the writer to be able to place a bbcode like tag with an attribute that will be replaced with a form, then a link once the form is submitted.

[download file="http://mywebsite.com/theFile.pdf"]The File[/download]

I guess what would help the most right now is how would I convert what's above into:

Download: <a href="http://mywebsite.com/theFile.pdf">The File</a>

Any thoughts? I'm guessing this is a regex question.

Thanks for the assist. :)
0
Comment
Question by:Ultrus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
thehagman earned 2000 total points
ID: 24328124
$output = preg_replace('/\[download file="([a-z0-9_]+\.[a-z]+)"\]([^\[]+)\[\/download\]/', '<a href="http://mywebsite.com/$1">$2</a>', $input);
0
 
LVL 10

Author Closing Comment

by:Ultrus
ID: 31579106
Sweet! That works great, and thank you very much!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question