Link to home
Start Free TrialLog in
Avatar of lawrence_dev
lawrence_dev

asked on

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)
Avatar of ozo
ozo
Flag of United States of America image

print "AIRFONIX AFX-19AR050 Active 50W Mono/25+25W Stereo" =~ /^([^a-z]*)\b/
Avatar of lawrence_dev
lawrence_dev

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Worked great!  Thanks for the help!
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