ninedoors Posted February 22, 2010 Share Posted February 22, 2010 I need to separate a string that holds information about a location on a warehouse floor. A sample string would be: 15B3 So that the '15' is tells me what bin location the product is in, the 'B' tells me the level of the racking it is on, and the '3' tells me where in that rack it is located. So what I need to do is separate this string when I get it out of a database so that I would have an array like array(15, B, 3) or some form of an array that I can get at each part. The string will always have the form of number string, letters string, number string. Like I said I am a newbie with regex so any help would be great. Looking thru what I have thru google, I looks like I would need something that looks for a group of digits or a group of alphas and returns it if found. Thanks Nick Quote Link to comment https://forums.phpfreaks.com/topic/192935-new-to-regex/ Share on other sites More sharing options...
sader Posted February 22, 2010 Share Posted February 22, 2010 heres the regexp for u if (preg_match('/(\\d+)(A|B|C|D|E|F)(\\d+)$/im', $str, $regs)) { $bin_loc = $regs[1]; $rack_level = $regs[2]; $rack_loc = $regs[3]; } but it might be that u can do this thing without preg functions Quote Link to comment https://forums.phpfreaks.com/topic/192935-new-to-regex/#findComment-1016153 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.