Jump to content


This topic is now archived and is closed to further replies.


getting 3 parts of a string

Recommended Posts

I looked at some tutorials and im always getting an error. here is what I have right now.

preg_match('dfgdfg d662dg d6dfggd', '/^[a-zA-Z0-9] [a-zA-Z0-9] [a-zA-Z0-9]$/', $return);

Its just a test. let me explain what Im trying to do.

In this text file there is 3 pieces of text, include numbers. like so

dfgdfg d662dg d6fghgd
dfgdfg d662dg d6456gd
dfsfgfg d662dg d6dfggd

When I read the file I read it line by line. so I can work with each one at a time. I need to split the line in to 3 pieces using the spaces inbetween them.

can anyone find what im doing wrong. oh yeah, here is the error I get:

Warning: preg_match(): Delimiter must not be alphanumeric or backslash


Share this post

Link to post
Share on other sites
Character classes [tt][...][/tt] only specify [u]one[/u] instance. Quantifiers need to be applied in order to look for more. You also have your regex and string in the wrong places. In this case, you're using the wrong tool for the job. Look at the explode function.

Share this post

Link to post
Share on other sites


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.