Please check the following paragraph for example.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad *minim veniam*, quis nostrud exercitation ullamco laboris *nisi ut* aliquip ex ea commodo consequat.
In the above paragraph "minim veniam" and "nisi ut" are inside asterisk. I want to remove those 2 sections from the above text. How to do it using PHP string handling? Please help.
I tried many thing with str_replace and preg_replace, but not working. Everytime it removes only the asterisk only. Not the text within it.
2
Answers
have you tried this regex?
I think the
preg_replace
will be the function that will help you.The pattern that can be used here is:
/*.*?*/
Example implementation: