Solved

string parser

Posted on 2006-11-23
6
237 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
Comment Utility
$newstring=ereg_replace('\"[a-z0-9]\"', $string,
                  '-');
0
 

Author Comment

by:brightwood
Comment Utility
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
Comment Utility
For example, "test 2.%a" should become "test-2a"
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 17

Expert Comment

by:HuyBD
Comment Utility

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

Accepted Solution

by:
HuyBD earned 500 total points
Comment Utility
sorry

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

Author Comment

by:brightwood
Comment Utility
this did the trick, thanks
0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
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 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 …

762 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

13 Experts available now in Live!

Get 1:1 Help Now