![]() |
Pulling info with Regular Expression...
Can someone help me pull information from this URL using regular
expression? http://www.amazon.com/exec/obidos/tg...750759-7559044 I want to pull the 15324461 from the url. Thanks, S. Cole |
Re: Pulling info with Regular Expression...
> "scole954387@gmail.com" <scole954387@gmail.com> wrote:
> news:1148756117.097541.308210@g10g2000cwb.googlegr oups.com.... > > Can someone help me pull information from this URL using regular > expression? > > http://www.amazon.com/exec/obidos/tg...750759-7559044 > > I want to pull the 15324461 from the url. > <script type="text/javascript"> var url='http://www.amazon.com/exec/obidos/tg/browse/'+ '-/15324461/ref=br_bx_c_1_129/103-6750759-7559044'; alert(url.match(/\d+/)) </script> -- BootNic Saturday, May 27, 2006 6:58 PM When I was younger, I could remember anything, whether it had happened or not. *Mark Twain* |
Re: Pulling info with Regular Expression...
Thanks for the reply.
Actually, this is what I have: <a href=/exec/obidos/tg/browse/-/########/ref=br_bx_c_1_2/104-1330076-7765538>Various Text</a> Using a regular expression (for use with preg_match in PHP), how can I just pull out the numbers (##########)? Thanks, S. Cole |
Re: Pulling info with Regular Expression...
I found a workaround that worked just as well. For anyone
interested... I took the url and exploded it by the "/". This created an array with each portion between the /s. All I had to do to access the numbers I wanted was to reference that part of the array. For example to access the "#########" I just had to reference $array[6]. S. Cole |
Re: Pulling info with Regular Expression...
scole954387 wrote:
> http://www.amazon.com/exec/obidos/tg...750759-7559044 You don't mention which programming language -- there are tonnes out there that each support their own idea of regular expressions. Using Perl: #!/usr/bin/perl $url = 'http://www.amazon.com/exec/obidos/tg/browse/-/15324461/ref=br_bx_c_1_129/103-6750759-7559044'; @parts = split(/\//, $url); $number = $parts[8]; print $number; Or in PHP, you probably don't even need regular expressions: <?php $url = 'http://www.amazon.com/exec/obidos/tg/browse/-/15324461/ref=br_bx_c_1_129/103-6750759-7559044'; $parts = explode('/', $url); $number = $parts[8]; print $number; ?> -- Toby A Inkster BSc (Hons) ARCS Contact Me ~ http://tobyinkster.co.uk/contact Now Playing ~ ./lighthouse_family/high.ogg |
Re: Pulling info with Regular Expression...
> "scole954387@gmail.com" <scole954387@gmail.com> wrote:
> news:1148783769.419269.149260@j73g2000cwa.googlegr oups.com.... > > Thanks for the reply. > > Actually, this is what I have: > > <a > href=/exec/obidos/tg/browse/-/########/ref=br_bx_c_1_2/104-1330076-7765538>Various > Text</a> > > Using a regular expression (for use with preg_match in PHP), how > can I just pull out the numbers (##########)? <?php $mystring="<a href='http://www.amazon.com/exec/obidos/tg/browse/-/15324461/ref=br_bx_c_1_129/103-6750759-7559044'>some text</a>"; $reg="/\d+/"; preg_match($reg, $mystring, $matches); print "Numbers are : {$matches[0]}"; ?> -- BootNic Sunday, May 28, 2006 2:41 PM Have no fear of perfection - you'll never reach it. *Salvador Dali* |
| All times are GMT. The time now is 10:22 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.