Solved

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

Posted on 2014-03-24
1
425 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 74

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now