Solved

PHP/REGEX: Wrap matches in span (Convert from ASP.NET/VB)

Posted on 2014-03-24
1
430 Views
Last Modified: 2014-03-24
Using PHP and Regular Expressions, how can I convert this:
- Hello World

Into this:
<span class="SpecialList">Hello World</span>

This ASP.NET/VB code works they way I want PHP code to work:
input =	RegularExpressions.Regex.Replace(input, "^- (?=[0-9a-zA-Z])([^\n]*)", "<span class=""SpecialList""> $1 </span>",RegexOptions.Multiline)

Open in new window

0
Comment
Question by:hankknight
1 Comment
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39950517
This should be equivelent:

$input = preg_replace("/^- (?=[0-9a-zA-Z])([^\n]*)/m", "<span class=\"SpecialList\"> $1 </span>", $input);

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

770 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