Re: help with preg_match pattern [message #184748 is a reply to message #184747] |
Tue, 28 January 2014 19:04 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 1/28/2014 1:53 PM, bill wrote:
> Yup managed to confuse myself reading the manual.
>
> I have an numerically indexed array that consists of fragments of a
> prescription.
> Rarely I may have an array element in the form of:
>
> [Alert: This Rx was initially created on 1/27/2014.]
>
> I want to delete those array elements (probably using array_slice), but
> first I need to figure out which array elements match the pattern. The
> date may change and will use one or two digit days and months.
> I could just look for the first part of the element, but I want to be
> prepared for the people upstream (over whom I have no influence -
> different company) to add other Alerts, some of which I will want to
> ignore, some of which I may want to keep.
>
> I am certainly open to other suggestions.
>
> bill
I'm not real good with regex's myself, but maybe something like this
will work:
^\s*\[Alert: This Rx was initially created on
[\d]{1,2}/[\d]{1,2}/[\d]{4}\.\]\s*$
Adjust as you see fit.
BTW, I find The Regex Coach (google for it - I don't have URL handy) to
be helpful in designing appropriate regex's.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
|
|
|