About 2,250,000 results
Open links in new tab
  1. javascript - What is the difference between substr and substring ...

    Sep 19, 2010 · I think the more important question is "why does JavaScript have both a substr method and a substring method"? This is really the preferred method of overloading?

  2. string - javascript substring - Stack Overflow

    Apr 4, 2013 · You're confusing substring() and substr(): substring() expects two indices and not offset and length. In your case, the indices are 5 and 2, ie characters 2..4 will be returned as …

  3. How to check whether a string contains a substring in JavaScript ...

    Nov 24, 2009 · Usually I would expect a String.contains() method, but there doesn't seem to be one. What is a reasonable way to check for this?

  4. javascript - What is the difference between String.slice and String ...

    Feb 11, 2010 · Distinctions of substring(): If start > stop, then substring will swap those 2 arguments. If either argument is negative or is NaN, it is treated as if it were 0. Distinctions of …

  5. How can I cut a substring from a string to the end using Javascript ...

    The native JavaScript String method substr [MDN] can accomplish what you need. Just supply the starting index and omit the length parameter, and it grabs all the way to the end. Now, how to …

  6. How to grab substring before a specified character in JavaScript?

    How to grab substring before a specified character in JavaScript? Asked 13 years, 9 months ago Modified 11 months ago Viewed 724k times

  7. How to get the nth occurrence in a string? - Stack Overflow

    I would like to get the starting position of the 2nd occurrence of ABC with something like this: var string = "XYZ 123 ABC 456 ABC 789 ABC"; getPosition (string, 'ABC', 2) // --> 16 How would …

  8. javascript - Get the text after a specific word - Stack Overflow

    Sep 3, 2014 · Let say I have the following strings: var Y = "TEST" var X = "abc 123 TEST 456 def" I would like to get the string from X that comes after the word that specified in Y. In this …

  9. How do I chop/slice/trim off last character in string using …

    Be aware that String.prototype.{ split, slice, substr, substring } operate on UTF-16 encoded strings None of the previous answers are Unicode-aware. Strings are encoded as UTF-16 in most …

  10. How can I get last characters of a string - Stack Overflow

    I get confused as to which language uses which substring command, looks like javascript can use either one though, although it looks like only substr works properly for negative numbers. …