Jump to content


Photo

getting 3 parts of a string


  • Please log in to reply
2 replies to this topic

#1 scs

scs
  • Members
  • PipPipPip
  • Advanced Member
  • 86 posts
  • LocationUSA

Posted 15 August 2006 - 08:44 PM

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

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 15 August 2006 - 08:46 PM

Character classes [...] only specify one 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.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 scs

scs
  • Members
  • PipPipPip
  • Advanced Member
  • 86 posts
  • LocationUSA

Posted 15 August 2006 - 08:48 PM

oh ok. Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users