Jump to content

preg_replace and wildcards


rfighter

Recommended Posts

Hi,

 

I am not really confident with the usage of preg_replace, and I would appreciate if someone could help me with the line of code.

 

I have a string, e.g. "sfsdfd sdfd

dfsdfsf
sfdfdf"

 

What I would like to do is replace the "

(* denoting wildcard) with just "[QUOT]".

 

Thanks!

 

^("QUOT" should be "QUOTE")

Link to comment
https://forums.phpfreaks.com/topic/117957-preg_replace-and-wildcards/
Share on other sites

preg_replace('/ - .*/i' , '', $text);

This should do the trick

 

Unfortunately that didn't work.

 

It turned:

[quote - xyz]

dfdfsdfsfsfsdsfdsfdsdsdsdsdsd

[END OF QUOTE]

 

Into:

 

[quote

 

I would like:

 

[quote]

dfdfsdfsfsfsdsfdsfdsdsdsdsdsd

[END OF QUOTE]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.