var n = parseInt(/\d/.exec("forum-list-1")[0]);

Or even easier using split (if you can rely on the format of the
string) - pretty much what Ariel already showed:

var n = parseInt("forum-list-1".split('-').pop());

--Klaus


On 15 Jun., 13:18, yo2lux <[EMAIL PROTECTED]> wrote:
> Thanks and which is the best way to obtain the last number of string,
> for example I have:
>
> forum-list-1
> forum-list-2
> forum-list-3
>
> I need the numbers: 1, 2 or 3.
>
> On Jun 12, 6:44 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
>
> > And that's why Ariel is da man! Nice one.
>
> > --Karl
> > ____________
> > Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> > On Jun 12, 2008, at 7:09 AM, Ariel Flesler wrote:
>
> > > Ooooooor....
>
> > > var fileName = $('img').attr('src').split('/').pop();
>
> > > Cheers :)
>
> > > --
> > > Ariel Flesler
> > >http://flesler.blogspot.com/
>
> > > On 11 jun, 22:29, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> > >> Hi there,
>
> > >> You could do it like this:
>
> > >> var path = $('img').attr('src');
> > >> var fileName = path.slice(path.lastIndexOf('/')+1);
>
> > >> --Karl
> > >> ____________
> > >> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> > >> On Jun 11, 2008, at 7:36 PM, yo2lux wrote:
>
> > >>> path variable store the following: /themes/mytheme/images/logo.gif:
>
> > >>> var path = $('img').attr('src');
>
> > >>> is possible to obtain the image name without path ? I need logo.gif
> > >>> I need a Javascript or jQuery function to solve this?
>
> > >>> Thanks!- Ocultar texto de la cita -
>
> > >> - Mostrar texto de la cita -

Reply via email to