here i'm working with php regular expression. in this project my leader said use only regular expression instead of PHP predefined function. i know the PHP string functions are simple to find output. but here i need to use regular expression.

this is the equivalent php function

$refined_output = str_replace('  ','',$stripped_result); 

i need the regular expression pattern equivalent the above php string function.

Member Avatar for diafol

So we're supposed to do your homework for you? Have you looked at preg_replace? Have you googled "replace multiple spaces regex" or similar? Sorry if this sounds a bit rude, but really?

you man. i did anumber of works on it. so what is for daniweb? i'm here to discuss about my coding trouble. don't be a jerk. this is not a rude dude.!!! i don't need your chicky comment

i need the regular expression pattern equivalent the above php string function.

What have you tried?

Why would you want to use a regular expression instead of str_replace? Not only is it a more complicated way to do a simple task but regular expressions require more resources for the same task.

You need to be more modest when you ask others to help you. Do not expect that people whom you ask would give you an answer, but do hope and appreciate if they do give you. You are not entitled to be given, simply said.

Aside from whatever I said, you need preg_replace() function to do what you want to do. You are still a newbie, so you can read about the function here. The pattern you want is \\s+ and you should read it here.

PS: Replacing using regex is much more powerful than suing str_replace. However, you could easily overuse when you deal with string manipulation.

Member Avatar for diafol

you man. i did anumber of works on it. so what is for daniweb? i'm here to discuss about my coding trouble. don't be a jerk. this is not a rude dude.!!! i don't need your chicky comment

Heh heh, sorry didn't understand much of your ghetto-talk, but I think I get the gist. Read the site guidelines and the forum sticky: http://bit.ly/Dwebphp

For example:

  • Do not ask for code. We are not a coding service. We will help you fix your code. If anyone posts a complete working solution for you, they are enabling cheaters. If you use that code you are a cheater.
  • Do not ask us to "take it easy on you."

Daniweb is here to help those that are prepared to help themselves. I gave you a few hints as to where you could start. If a Google search is beyond you, then I suggest a career or course in programming will be far too demanding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.