Solved

string parser

Posted on 2006-11-23
6
242 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
[X]
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
  • 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

636 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