Need assistance with REGEX statement

How do I grab just "AIRFONIX AFX-19AR050" from this statement?  (I have multiple statements structured the same way)  Basically, I need everything before the Upper and Lower Case text starts 'Active 50W Mono/25+25W Stereo'.  

AIRFONIX AFX-19AR050 Active 50W Mono/25+25W Stereo

(Brand and Stock Number followed by description)
lawrence_devAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ozoConnect With a Mentor Commented:
#!/bin/php
<?php
$title="AIRFONIX AFX-19AR050 Active 50W Mono/25+25W Stereo";

preg_match('%^([^a-z]*)\b%',$title,$matches51);

$BrandMPN=$matches51[1];

echo "BrandMPN:&nbsp;&nbsp;".$BrandMPN."<BR>";
?>
0
 
ozoCommented:
print "AIRFONIX AFX-19AR050 Active 50W Mono/25+25W Stereo" =~ /^([^a-z]*)\b/
0
 
lawrence_devAuthor Commented:
THANKS!!   How do I preg match an existing variable with your regex:   ($title is the existing variable)

preg_match('%^([^a-z]*)\b%',$title,$matches51);

$BrandMPN=$matches51[1];

echo "BrandMPN:&nbsp;&nbsp;".$BrandMPN."<BR>";

Open in new window

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Ray PaseurCommented:
From the look of this and your other recent questions it appears that you're trying to scrape product information from an eCommerce web site.  There are many well-understood design patterns that can help.  If you want to show us a link to the page you're trying to scrape, or at least a few samples of the "multiple statements structured the same way" E-E may be able to help you make very rapid progress toward your goal.
0
 
lawrence_devAuthor Commented:
Worked great!  Thanks for the help!
0
 
Ray PaseurCommented:
For anyone coming upon this question in the future, please be aware that the regular expression used as a solution here says, in essence, "match the absence of the lower-case characters up to the first word boundary."  One good learning resource for regular expressions is available here:
http://www.regular-expressions.info/tutorial.html
0
All Courses

From novice to tech pro — start learning today.