Skip to content
Advertisement

Tag: string

Parse string in javascript

How can I parse this string on a javascript, var string = “http://www.facebook.com/photo.php?fbid=322916384419110&set=a.265956512115091.68575.100001022542275&type=1”; I just want to get the “265956512115091” on the string. I somehow parse this string but, still not enough to get what I wanted. my code: returns: Answer http://jsbin.com/anuhog/edit#source

How to trim a string to N chars in Javascript?

How can I, using Javascript, make a function that will trim string passed as argument, to a specified length, also passed as argument. For example: Anyone got ideas? I’ve heard something about using substring, but didn’t quite understand. Answer Why not just use substring… string.substring(0, 7); The first argument (0) is the starting point. The second argument (7) is the

Split large string in n-size chunks in JavaScript

I would like to split a very large string (let’s say, 10,000 characters) into N-size chunks. What would be the best way in terms of performance to do this? For instance: “1234567890” split by 2 would become [“12”, “34”, “56”, “78”, “90”]. Would something like this be possible using String.prototype.match and if so, would that be the best way to

Convert string to datetime

How to convert string like ’01-01-1970 00:03:44′ to datetime? Answer For this format (assuming datepart has the format dd-mm-yyyy) in plain javascript use dateString2Date. It may bite you, because of browser compatibility problems. tryParseDateFromString is ES6 utility method to parse a date string using a format string parameter (format) to inform the method about the position of date/month/year in the

Advertisement