My regex kung-fu is not strong =(


Joined
Apr 4, 2020
Messages
1
Reaction score
0
Hello!

I'm trying to stumble by getting a pattern match. Now, I can get once instance of how it could be it's the second that I'm not really wrapping my head around.

Here's my test text :
Order date: Mar 13, 2020 11:36:50 PM EDT
Item Price
Starter Pack! (Celeb Chef: Serving The Celebrity) $0.99
Tax: $0.07
Total: $1.06
Payment method:
Visa-1447
Play Points earned
+1

Order date: Mar 14, 2020 11:40:43 AM EDT
Item Price
Mini Gem Pack (Celeb Chef: Serving The Celebrity) $1.99
Tax: $0.14
Total: $2.13
Payment methods:
Google Play balance: $1.81
Visa-1447 : $0.32
Play Points earned
+2

I'm using this regex:
preg_match_all('/Payment method:\W+(.+)/m', $input_lines, $output_array);

I got the first 'Visa-1447' what I'm having the trouble is capturing the lower one that has two payment methods with the dollar amount after them!

Don't know what's frustrating me more; figuring this out or being kept hostage inside cause of this pandemic thing! :mad:

So if you could help me out I'd appreciate it! But I ask one thing so I can understand and absorb is tell me the how and why!

Thank you way in advance!

Handler
 
Ad

Advertisements


Top