![]() ![]() ![]() () Returns the index within the calling String object of the last occurrence of searchValue, or -1 if not found. The way it was originally written looks for '2,'.Īlso to reinforce what Klaus said, if you have control over the way the data is handled you may find it easier to store lists of values in an array. Returns a boolean indicating whether this string contains any lone surrogates. The value checked by topPage.indexOf() does not need the added comma. The only change was to remove the trailing comma from temp value - your comma delimited string does not end with a comma, so it could never find the last value. ![]() String.Search(searchValueRegex) returns an index integer or -1 if the string isn't found. The includes () method performs a case-sensitive search to determine whether one string may be found within another string, returning true or false as appropriate.String.Matches(searchValueRegex) returns an array including all matches or null if not found. 10 Answers Sorted by: 406 You have three possibilites: Regular expression: (new RegExp ('word')).test (str) // or /word/.test (str) indexOf: str.indexOf ('word') -1 includes: str.includes ('word') Regular expressions seem to be faster (at least in Chrome 10).String.indexOf(searchValueString, offsetInteger) returns an index integer or -1 if the string isn't found.While Klaus is correct that you are working with integers, they arrive at your code as a single string, so it's a valid question. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |