Friday 15 August 2014

javascript - Split a string of file input field -


I need to get a value in a form from the input field, I just need the filename, the string looks like this :

  var str = 'C: \ users \ user \ desktop \ file_name.ext';   

If I try to run (yes, the backslash is saved)

  str.split (\\) [str.length-1]   

This does not work, because the slash in the string is not saved. Simple console.log (str) gives me C: UsersUserDesktopile_name.ext and you see how the problem is where do I get around it?

  'c: \ user \ user \ desktop \ file_name .ext'.split (/ \\ | //) Pop () ;.   

Backlash escapes I am confusing people by escaping my backslash. The above string is "like".

No comments:

Post a Comment