Jump to content

getting 3 parts of a string


scs

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

thanx
zach
Link to comment
https://forums.phpfreaks.com/topic/17675-getting-3-parts-of-a-string/
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.

Archived

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

×
×
  • Create New...

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.