Passing a commented, multi-line (freespace) regex to preg_match

Question :

Passing a commented, multi-line (freespace) regex to preg_match,

Answer :

I have a regex that is going to end up being a bit long and it’d make it much easier to read to have it across multiple lines.

I tried this but it just barfs.

preg_match(      '^J[0-9]{7}:s+      (.*?)             #Extract the Transaction Start Date msg      s+J[0-9]{7}:s+Projectsname:s+      (.*?)             #Extract the Project Name      s+J[0-9]{7}:s+Jobsname:s+      (.*?)             #Extract the Job Name      s+J[0-9]{7}:s+',      $this->getResultVar('FullMessage'),      $atmp  );  

Is there are way to pass a regex in the above form to preg_match?

,

You can use the extended syntax:

preg_match("/      test  /x", $foo, $bar);  

That’s the answer Passing a commented, multi-line (freespace) regex to preg_match, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  .NET obfuscation tools/strategy

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you