How to get all string after last "/"

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get all string after last "/"

abbat81
Hi,

I have a links with one and more "/".
example:
http://www.link1.com/folder1/picture1.png
http://www.link2.com/folder2/folder3/picture2_adv.png

How to get "picture1.png" and "picture2_adv.png" from those links?

Thanks
Reply | Threaded
Open this post in threaded view
|

R: How to get all string after last "/"

Ru Vuott
Hello Abbat81,

...by using Split() function:


Public Sub Form_Open()

  Dim s As String = "http://www.link1.com/folder1/picture1.png"
  Dim ss As String[]

   ss = Split(s, "/")
   
   Print ss[4]

End



--------------------------------------------
Gio 22/8/13, abbat81 <[hidden email]> ha scritto:

 Oggetto: [Gambas-user] How to get all string after last "/"
 A: [hidden email]
 Data: Giovedì 22 agosto 2013, 20:23
 
 Hi,
 
 I have a links with one and more "/".
 example:
 http://www.link1.com/folder1/picture1.png
 http://www.link2.com/folder2/folder3/picture2_adv.png
 
 How to get "picture1.png" and "picture2_adv.png" from those
 links?
 
 Thanks
 
 
 
 --
 View this message in context: http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952.html
 Sent from the gambas-user mailing list archive at
 Nabble.com.
 
 ------------------------------------------------------------------------------
 Introducing Performance Central, a new site from SourceForge
 and
 AppDynamics. Performance Central is your source for news,
 insights,
 analysis and resources for efficient Application Performance
 Management.
 Visit us today!
 http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
 _______________________________________________
 Gambas-user mailing list
 [hidden email]
 https://lists.sourceforge.net/lists/listinfo/gambas-user
 

------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

abbat81
Ru Vuott wrote
Hello Abbat81,
  Dim s As String = "http://www.link1.com/folder1/picture1.png"
     
   Print ss[4]

End
But link can contain a different count of "/"


example:
 http://www.link1.com/folder1/picture1.png
 http://www.link2.com/folder2/folder3/picture2_adv.png


Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

jsbsan
In this way you can extract the file name of a given route (from the last "
/").

What I do is a countdown until you find the character "/":


Public Sub extraedesdebarra(ruta As String) As String

  Dim a As Integer
  Dim letra As String
  Dim cadena As String

  For a = Len(ruta) To 1 Step -1
    letra = Mid$(ruta, a, 1)
    If letra = "/" Then
      Return cadena
    Else
      cadena = letra & cadena
    Endif

  Next

End


2013/8/22 abbat81 <[hidden email]>

> Ru Vuott wrote
> > Hello Abbat81,
> >   Dim s As String = "http://www.link1.com/folder1/picture1.png"
> >
> >    Print ss[4]
> >
> > End
>
> But link can contain a different count of "/"
>
>
> example:
>  http://www.link1.com/folder1/picture1.png
>  http://www.link2.com/folder2/folder3/picture2_adv.png
>
>
>
>
>
>
> --
> View this message in context:
> http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42955.html
> Sent from the gambas-user mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

Jussi Lahtinen
In reply to this post by abbat81
You can use InStr() to find "png" and count back to "/".

Jussi


On Thu, Aug 22, 2013 at 10:22 PM, abbat81 <[hidden email]> wrote:

> Ru Vuott wrote
> > Hello Abbat81,
> >   Dim s As String = "http://www.link1.com/folder1/picture1.png"
> >
> >    Print ss[4]
> >
> > End
>
> But link can contain a different count of "/"
>
>
> example:
>  http://www.link1.com/folder1/picture1.png
>  http://www.link2.com/folder2/folder3/picture2_adv.png
>
>
>
>
>
>
> --
> View this message in context:
> http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42955.html
> Sent from the gambas-user mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

abbat81
Jussi Lahtinen wrote
You can use InStr() to find "png" and count back to "/".
Ok, how to count back to last "/" in string if we have:

Dim s As String = "http://www.link1.com/folder1/folder1/picture1.png"
Print InStr(s, ".png")

 => 46
Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

Fabien Bodard-4
:-)

StrName = File.Name("http://www.link1.com/folder1/picture1.png")

http://gambasdoc.org/help/comp/gb/file/name?v3


2013/8/22 abbat81 <[hidden email]>

> Jussi Lahtinen wrote
> > You can use InStr() to find "png" and count back to "/".
>
> Ok, how to count back to last "/" in string if we have:
>
> Dim s As String = "http://www.link1.com/folder1/folder1/picture1.png"
> Print InStr(s, ".png")
>
>  => 46
>
>
>
> --
> View this message in context:
> http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42961.html
> Sent from the gambas-user mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fabien Bodard
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

abbat81
In reply to this post by Ru Vuott
Thank you very much

It was helpfull + Array.Count:

  Dim s As String = "http://www.link1.com/folder1/folder1/picture1.png"
  Dim ss As String[]

   ss = Split(s, "/")
   
   Print ss[ss.count - 1]


Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

Jussi Lahtinen
In reply to this post by Fabien Bodard-4
Oh yes, that is best way to do that!

Jussi


On Thu, Aug 22, 2013 at 11:14 PM, Fabien Bodard <[hidden email]> wrote:

> :-)
>
> StrName = File.Name("http://www.link1.com/folder1/picture1.png")
>
> http://gambasdoc.org/help/comp/gb/file/name?v3
>
>
> 2013/8/22 abbat81 <[hidden email]>
>
> > Jussi Lahtinen wrote
> > > You can use InStr() to find "png" and count back to "/".
> >
> > Ok, how to count back to last "/" in string if we have:
> >
> > Dim s As String = "http://www.link1.com/folder1/folder1/picture1.png"
> > Print InStr(s, ".png")
> >
> >  => 46
> >
> >
> >
> > --
> > View this message in context:
> >
> http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42961.html
> > Sent from the gambas-user mailing list archive at Nabble.com.
> >
> >
> >
> ------------------------------------------------------------------------------
> > Introducing Performance Central, a new site from SourceForge and
> > AppDynamics. Performance Central is your source for news, insights,
> > analysis and resources for efficient Application Performance Management.
> > Visit us today!
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> > _______________________________________________
> > Gambas-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
>
>
> --
> Fabien Bodard
>
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

paulwheeler
In reply to this post by Jussi Lahtinen

   Here is the code to do the extraction:
   Dim intSlash As Integer
       Dim strPictureName As String
       Dim strLinkAddress As String =
   [1]"http://www.link1.com/folder1/folder1/picture1.png"
       '' Find location of last slash in address:
       intSlash = RInStr(strLinkAddress, "/")
       '' Extract information starting after that slash:
       strPictureName = Right$(strLinkAddress, Len(strLinkAddress) - intSlash)
       '' Voila! strPictureName is now just the filename and extension!
       Print "strPictureName = " & strPictureName
   Paul

   On 08/22/2013 01:06 PM, abbat81 wrote:

Jussi Lahtinen wrote

You can use InStr() to find "png" and count back to "/".

Ok, how to count back to last "/" in string if we have:

Dim s As String = [2]"http://www.link1.com/folder1/folder1/picture1.png"
Print InStr(s, ".png")

 => 46



--
View this message in context: [3]http://gambas.8142.n7.nabble.com/How-to-get-al
l-string-after-last-tp42952p42961.html
Sent from the gambas-user mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
[4]http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[5][hidden email]
[6]https://lists.sourceforge.net/lists/listinfo/gambas-user

References

   1. http://www.link1.com/folder1/folder1/picture1.png
   2. http://www.link1.com/folder1/folder1/picture1.png
   3. http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42961.html
   4. http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
   5. mailto:[hidden email]
   6. https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

paulwheeler
In reply to this post by abbat81

   Very interesting that g3 treats a web address the same as a file name.
   Definitely easier than my code, and something to remember! Thanks Fabien!
   paul

   On 08/22/2013 01:14 PM, Fabien Bodard wrote:

:-)

StrName = File.Name([1]"http://www.link1.com/folder1/picture1.png")

[2]http://gambasdoc.org/help/comp/gb/file/name?v3


2013/8/22 abbat81 [3]<[hidden email]>

Jussi Lahtinen wrote

You can use InStr() to find "png" and count back to "/".

Ok, how to count back to last "/" in string if we have:

Dim s As String = [4]"http://www.link1.com/folder1/folder1/picture1.png"
Print InStr(s, ".png")

 => 46



--
View this message in context:
[5]http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42
961.html
Sent from the gambas-user mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
[6]http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[7][hidden email]
[8]https://lists.sourceforge.net/lists/listinfo/gambas-user

References

   1. http://www.link1.com/folder1/picture1.png
   2. http://gambasdoc.org/help/comp/gb/file/name?v3
   3. mailto:[hidden email]
   4. http://www.link1.com/folder1/folder1/picture1.png
   5. http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42961.html
   6. http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
   7. mailto:[hidden email]
   8. https://lists.sourceforge.net/lists/listinfo/gambas-user
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: R: How to get all string after last "/"

Fabien Bodard-4
2013/8/23 paulwheeler <[hidden email]>

>
>    Very interesting that g3 treats a web address the same as a file name.
>    Definitely easier than my code, and something to remember! Thanks
> Fabien!
>    paul
>
> It's not the fact of Gambas ... But a web address look like a file address
on unix.


http://folder/flie.ext
/folder/file.ext
file://folder/file.ext
ftp://folder/file.ext... etc


file.Name
File.BaseName
File.ext

do just the job that the above gb code do ... but more faster.



>    On 08/22/2013 01:14 PM, Fabien Bodard wrote:
>
> :-)
>
> StrName = File.Name([1]"http://www.link1.com/folder1/picture1.png")
>
> [2]http://gambasdoc.org/help/comp/gb/file/name?v3
>
>
> 2013/8/22 abbat81 [3]<[hidden email]>
>
> Jussi Lahtinen wrote
>
> You can use InStr() to find "png" and count back to "/".
>
> Ok, how to count back to last "/" in string if we have:
>
> Dim s As String = [4]"http://www.link1.com/folder1/folder1/picture1.png"
> Print InStr(s, ".png")
>
>  => 46
>
>
>
> --
> View this message in context:
> [5]
> http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42
> 961.html
> Sent from the gambas-user mailing list archive at Nabble.com.
>
>
>
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> [6]
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> [7][hidden email]
> [8]https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> References
>
>    1. http://www.link1.com/folder1/picture1.png
>    2. http://gambasdoc.org/help/comp/gb/file/name?v3
>    3. mailto:[hidden email]
>    4. http://www.link1.com/folder1/folder1/picture1.png
>    5.
> http://gambas.8142.n7.nabble.com/How-to-get-all-string-after-last-tp42952p42961.html
>    6.
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
>    7. mailto:[hidden email]
>    8. https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> ------------------------------------------------------------------------------
> Introducing Performance Central, a new site from SourceForge and
> AppDynamics. Performance Central is your source for news, insights,
> analysis and resources for efficient Application Performance Management.
> Visit us today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fabien Bodard
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user