Sasa Posted February 8, 2008 Report Share Posted February 8, 2008 kā es no šitā stringa varu dabūt taikai faila nosaukumu. C:\Documents and Settings\olga\Desktop\kdbvs_bildes\G51_bildes\G51-1.jpg Link to comment Share on other sites More sharing options...
v3rb0 Posted February 8, 2008 Report Share Posted February 8, 2008 basename Link to comment Share on other sites More sharing options...
Aleksejs Posted February 8, 2008 Report Share Posted February 8, 2008 basename, šķiet ir tikai PHP, bet ne JavaScript/VBscript Link to comment Share on other sites More sharing options...
Sasa Posted February 8, 2008 Author Report Share Posted February 8, 2008 atradu tādu lietu bet kas tā tāda ir nezinu: var a="/usr/local/test.txt"; var b=a.match(/[\/|\\]([^\\\/]+)$/); alert( b[1] ); strādāt strādā ... kādā veidā nesaprotu :) Link to comment Share on other sites More sharing options...
andrisp Posted February 8, 2008 Report Share Posted February 8, 2008 regulārās ekspresijas. Link to comment Share on other sites More sharing options...
v3rb0 Posted February 8, 2008 Report Share Posted February 8, 2008 nevajag tur regex. ja ir windowsveidīgs ceļš, tad pārvēršam to par "pareiza" formāta ceļu, sasplitojam pēc / un paņemam pēdējo masīva elementu. var path = "C:\\Documents and Settings\\olga\\Desktop\\kdbvs_bildes\\G51_bildes\\G51-1.jpg"; path.replace("\\",'/').split("\\").slice(-1); Link to comment Share on other sites More sharing options...
andrisp Posted February 8, 2008 Report Share Posted February 8, 2008 v3rb0, a tu zināji, ka replace un split ari izmanto regulārās ekspressijas ? :) tā kā no ātrdarbības viedokļa tavs variants pat varētu būt lēnāks. Link to comment Share on other sites More sharing options...
Recommended Posts