This should do the trick: /(\d+) ?X ?(\d+) ?X ?(\d+ [\d\/]+)/i (at least it would in Perl) Le 13 Janvier 2006 08:25, Mike Smith a écrit : > 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 )/ > > I have: > 102-90 E [!MATCH!] [!MATCH!] 70 3/8 > > > 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 > > $pattern1 = '/[0-9]{2,}( X| x|x )/'; > $units = array of units above > foreach($units AS $unit){ > preg_match($pattern1,$unit[1],$match); > print_r($match); > echo "Panel: ".$match[0]; > } > > The $match array is empty. > > Actually looking at the data there are so many typos (imported from > Excel) that I will probably have to update by hand, but out of > curiosity now what would be a good regex for the info given? > > Thanks, > Mike Smith -- Eric Martel Sainte-Foy (Québec) Canada Ce courriel est signé numériquement avec la clef suivante: This e-mail is digitally signed with the following key: ED3F191C (key://pgp.mit.edu, http://key.ericmartel.net/) Empreinte/fingerprint: 023D EFB7 8957 CBC0 C4E7 243D F01E D8A8 ED3F 191C Pour plus d'information: http://gpg.ericmartel.net/ For more info: http://kmself.home.netcom.com/Rants/gpg-signed-mail.html "There are flaws in Windows so great that they would threaten national security if the Windows source code were to be disclosed." --Microsoft VP Jim Allchin, under oath "The intrinsic parallelism and free idea exchange in open source software has benefits that are not replicable with our current licensing model." --Microsoft Read more on http://opensource.org/halloween/ Read between lines: get Linux! It's free, open source, more secure, more reliable and more performant than Window$. http://www.linuxiso.org/
Attachment:
pgpqXIB4wwbJF.pgp
Description: PGP signature