Re: Regex help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 13, 2006 at 08:25:57AM -0500, Mike Smith wrote:
> I'm trying to save myself some time by extracting certain variables
> from a string:
> 
> 102-90 E 42 X 42 X 70 3/8
> 
> I've been testing with: http://www.quanetic.com/regex.php
> and have been somewhat successful. Using this pattern:
> /[0-9]{2,}( X| x|x )/

The biggest problem with trying to match a string with regex is you
have to know the definition of what the string can be, for example
can the data be:
  
   102-90 E 42  X 42 X 70 3/8
   102-90 E 42 X  42 X 70 3/8
   102-90 E 42X42X70 3/8
   102-90 E 42\tX\t  42 \t X\n 70\r\n 3/8

> 
> I have:
> 102-90 E [!MATCH!] [!MATCH!] 70 3/8

If you want to just match those two numbers then:

  /\s+(\d{1,2})\s+(X|x)\s+(\d{1,2})\s+(X|x)\s+/

> 
> 
> Ideally what I want to do is update the db table that holds these records.
> ID: 1
> Unit: 102-90 E 42 X 42 X 70 3/8
> Panel: 42
> Width: 42
> Height: 70 3/8

If this is the case, where does the 102-90 E come from? This sounds
more like a data normalization issue than anything.
 
Curt.
-- 
cat .signature: No such file or directory

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux