# String Splitters

**URL:** https://forum.kirupa.com/t/string-splitters/179287
**Category:** programming
**Created:** [February 18, 2006, 2:06pm UTC](https://forum.kirupa.com/t/string-splitters/179287 "2006-02-18T14:06:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Sliker\_Hawk](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Sliker\_Hawk](https://forum.kirupa.com/u/Sliker_Hawk)
#### Post date: [February 18, 2006, 2:06pm UTC](https://forum.kirupa.com/t/string-splitters/179287/1 "2006-02-18T14:06:57Z")

</div>

A new movie…  
Uh, anyway, say I have a string like this:

$num = “Hello 2890. How are you?”;

I want that to be split up so that the number is in a seperate string, as such:

$num\_num = “2890”;

Now, I havn’t tried this, but if it’s right, just tell me and I’ll be ashamed for not trying it first; could I do that with a function like this:

$num\_num = preg\_split("(.?)_[0-9]+(.?)_", $num);

What confuses me about that is that both the '(.?)\*'s would be saved into the string aswell. I think… Anyway, can anyone enlighten me?

edit: or preg\_split(".?_([0-9])+.?_", $num);  
That way the '.?\*'s wouldn’t be counted as an output thingy… I’ll shut up. I havn’t done this for a while, so I’m a bit rusty…
