regex help needed |
I've been trying to figure this out for awhile, so it must be time to ask for help. How can I get the results I want?
Code: $subject = '\n MC - 5-10 OVER IN A CHURCH ZONE - 12/08/15\n INF - 1-5 OVER IN A SCHOOL ZONE - 12/14/15\n';
(05-09-2016, 09:54 AM)cupboy Wrote: I've been trying to figure this out for awhile, so it must be time to ask for help. How can I get the results I want? is the information you're going to be getting always in this format?
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
In regex, to recognize a space character, use \s
To get a match for multiple space characters, use \s+
Regular Expression online tester RegExr.
Online RegX Tester What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I figured out how to get the results. It's a two step process though. Probably is a better way. For the time being the 2nd process is a little bit like this:
Code: $pattern = '/([MF].|INF|CAP) \- /'; Array ( [0] => [1] => MA [2] => POSSESSION OR USE OF A CONTROLLED SUBSTANCE - 10/23/14 [3] => MA [4] => USE OR POSSESSION OF DRUG PARAPHERNALIA - ) .. everything is split up the way I want it (the dates I don't need but I can use a third process to dump those) |
Welcome Guest, Not a member yet? Register Sign In |