Jump to content

Problem with a regex


Recommended Posts

Well, its my first time using regex and I'm having a bit of a problem: I need to split the following string:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
a:6:{s:12:"firstinsertd";s:10:"01-01-1970";s:12:"firstinsertt";s:8:"01:00 AM";s:7:"updated";s:10:"10-13-2005";s:7:"updatet";s:8:"05:37 PM";s:6:"amount";d:51218.2087766306431149132549762725830078125;s:10:"updatetime";i:1131550652;}
[/quote]
So I can get the amount (512218) alone, without the decimal, or ;d:... But I just can't figure out how to do it.

Heres my regex, which seems to return the number AFTER the decimal as [1] in the array (Along with ";s:10:"updatetime";i:1131550652;} )", for some reason) :
[code]
$ucashbank = 'a:6:{s:12:"firstinsertd";s:10:"01-01-1970";s:12:"firstinsertt";s:8:"01:00 AM";s:7:"updated";s:10:"10-13-2005";s:7:"updatet";s:8:"05:37 PM";s:6:"amount";d:51218.2087766306431149132549762725830078125;s:10:"updatetime";i:1131550652;}';


$test = preg_split("/amount\";[d]:([0-9])*[.]/", $ucashbank);
print_r($test);
[/code]

Returns:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Array ( [0] => a:6:{s:12:"firstinsertd";s:10:"01-01-1970";s:12:"firstinsertt";s:8:"01:00 AM";s:7:"updated";s:10:"10-13-2005";s:7:"updatet";s:8:"05:37 PM";s:6:" [1] => 2087766306431149132549762725830078125;s:10:"updatetime";i:1131550652;} )
[/quote]

Anyone know what I'm doing wrong?
Link to comment
https://forums.phpfreaks.com/topic/4138-problem-with-a-regex/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.