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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

Title # Comments Views Activity
Difference between PHPClasse.php and SimplXLS.php 5 47
Regular Expression needed 4 44
phpmyadmin memory error 55 95
Tell me if I understand this correctly... 6 20
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.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 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