Some regex help

Posted on 2013-11-10
Last Modified: 2013-11-10
I need to turn
Size{2} :  L/XL[22], S/M[19]



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

Accepted Solution

Terry Woods earned 500 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.
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.
LVL 58

Author Closing Comment

ID: 39637676
Nope, that works perfect

(I hate regex)

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Introduction This article is intended for those who are new to PHP error handling (  It addresses one of the most common problems that plague beginning PHP develop…
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…
The viewer will learn how to count occurrences of each item in an array.

623 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