seperating text from numbers in a varchar

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
massiveone
Forum Commoner
Posts: 29
Joined: Tue Jun 18, 2002 4:39 pm
Location: Canada
Contact:

seperating text from numbers in a varchar

Post by massiveone »

how can i seperate characters from numbers in a varchar?
for example if i have a varchar in sql with the data hello123 how can i out put it so that it will seperate it into two variables $textstuff and $numberstuff?

anyhelp would be g8ly appreciated.

Thanks
:?:
chris12295
Forum Contributor
Posts: 113
Joined: Sun Jun 09, 2002 10:28 pm
Location: USA
Contact:

Post by chris12295 »

the split() function in PHP will allow regular expressions so possibly:

Code: Select all

$newText = split("їA-Za-z]*ї0-9]*", $text);
$textstuff = $newTextї0];
$numberStuff = $newTextї1];
This might not work as I have not tested it but this page will explain the split function. http://www.php.net/manual/en/function.split.php
User avatar
massiveone
Forum Commoner
Posts: 29
Joined: Tue Jun 18, 2002 4:39 pm
Location: Canada
Contact:

doh

Post by massiveone »

ok code dosnt work but i get the point your make ;)
Thanks for the help
Post Reply