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
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.