Solved

string parser

Posted on 2006-11-23
6
239 Views
Last Modified: 2006-11-23
How can I replace everything that is not a-z0-9 in a string with "" and " " with "-"

Thank you in advance
0
Comment
Question by:brightwood
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:HuyBD
ID: 18005429
$newstring=ereg_replace('\"[a-z0-9]\"', $string,
                  '-');
0
 

Author Comment

by:brightwood
ID: 18005448
I don't think I explained it good enough.
I want to:
1. replace " " with "-"
2. replace every character that is not letter, number, or "-" with ""
0
 

Author Comment

by:brightwood
ID: 18005456
For example, "test 2.%a" should become "test-2a"
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 17

Expert Comment

by:HuyBD
ID: 18005526

$newstring=ereg_replace('[^a-zA-Z0-9]','', $string);
0
 
LVL 17

Accepted Solution

by:
HuyBD earned 500 total points
ID: 18005576
sorry

$newstring=ereg_replace('[^a-zA-Z0-9-]','',ereg_replace(' ','-',$string));
0
 

Author Comment

by:brightwood
ID: 18005605
this did the trick, thanks
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

770 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