Is there a way to grab strings that match patterns --*-- and ++*++ (two seperate queries) where * is a wildcard and --, ++, are criteria to meet. I'd like to write matches within variable fully, like --daniweb.com-- and ++this just an example++.

preg_match() provides solution on alphanumerical identities. And there's been about 3 pages which focus grabbing all special characters, however, I need to focus these two. As I need to replace these two of these in future (after I find out the variables within -- or ++).

Edited by Aeonix

1 Year
Discussion Span
Last Post by Aeonix

/--(.*?)--/ and /\+\+(.*?)\+\+/ should do it. Do you need them in one?


Votes + Comments
Perfect answer.

The answer is perfect. But apparently I asked incorrect question. preg_match() bring up bool whether match has been found, not the content of match (how foolish of me).

The contents of --this is an example--. I need to retrieve them, as there are variables and settings within the double --. So I would need to find them match, retrieve it's content (and then I know exactly how), explode the content, execute function properly and replace the found line.

Do you have any recommendations on where to learn tricks you provided? So far I look at it, it looks like black magic, any recommendations on where I could puzzle upon it?

Edited by Aeonix


So far I look at it, it looks like black magic,

It is. pritaeas is a Wizard. I failed my apprenticeship :(

Votes + Comments
All bow to Senpai Pritaeas!


I can recommend RegexBuddy from JGSoft. You can build, test and store expressions. The site regular-expressions.info is a good starting point for more info on regexes. hth.


As stupid as one can get, putting in third parameter called $matches, has granted me access to array with all hits. So easy, yet so hard to find.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.