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
Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
parse a file and get data out 11 78
Ajax php search with multiple text fields generated by php 38 71
What if i make webbased alternative for MS Access 5 71
Ajax and PHP 4 31
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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.
The viewer will learn how to count occurrences of each item in an array.
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.

828 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