Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Some regex help

Posted on 2013-11-10
3
Medium Priority
?
225 Views
Last Modified: 2013-11-10
Hi
I need to turn
Size{2} :  L/XL[22], S/M[19]

into

Size:L/XL,S/M

This is just an example, Size could be Colour or Style etc and the size options could be numerous.
0
Comment
Question by:Gary
[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
3 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 2000 total points
ID: 39637667
One option would be to remove particular characters:

$data = preg_replace('#[{}\[\]\d ]#', '', $data);

Open in new window


That worked for me.
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 39637668
If you need to retain numbers that aren't in braces/brackets, then let me know.
0
 
LVL 58

Author Closing Comment

by:Gary
ID: 39637676
Nope, that works perfect
Thanks

(I hate regex)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
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.

722 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