Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   Pulling info with Regular Expression... (http://www.velocityreviews.com/forums/t295360-pulling-info-with-regular-expression.html)

scole954387@gmail.com 05-27-2006 06:55 PM

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


BootNic 05-27-2006 10:58 PM

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*


scole954387@gmail.com 05-28-2006 02:36 AM

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


scole954387@gmail.com 05-28-2006 05:11 AM

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


Toby Inkster 05-28-2006 09:39 AM

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


BootNic 05-28-2006 06:41 PM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57