How to split the following strings into prefix, range and postfix?


#1

Hi,

I have following type of strings which has to be split into prefix, range and postfix. In the following m or 3m is prefix, 123 is range and lg is postfix. I need some way so that if any type of the combination is provided then prefix, range and postfix is successfully determined.


123
m123
3m123
3m123lg
123lg


I have tried several ways, but I am not able to do it perfectly.

For example I tried this code: preg_match_all('/([0-9]+|[a-zA-Z]+)/', $str , $arr); which splits the string into chars and numbers but in this if the string is 3m123 then I get 3,m, 123 and I am not able to determine if 3,m is prefix or not...

Please help.

Thanks.


#2

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.