Solved

Some regex help

Posted on 2013-11-10
3
203 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
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
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.
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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 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 …

929 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

14 Experts available now in Live!

Get 1:1 Help Now