Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.