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 ++).

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

--(.*?)--|\+\+(.*?)\+\+

commented: Perfect answer. +4

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?

Member Avatar for diafol

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

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

commented: All bow to Senpai Pritaeas! +4

lol.

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.

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.