Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Some regex help

Posted on 2013-11-10
3
Medium Priority
?
227 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

971 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