{"id":19411,"date":"2017-01-02T19:33:09","date_gmt":"2017-01-02T19:33:09","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=19411"},"modified":"2017-01-02T19:33:09","modified_gmt":"2017-01-02T19:33:09","slug":"javascript-string-functions-substr-vs-substring","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/javascript-string-functions-substr-vs-substring\/","title":{"rendered":"JavaScript:  string functions:  substr() vs substring()"},"content":{"rendered":"<h1>The tutor describes the difference between substr() and substring()<\/h1>\n<p>Let&#8217;s imagine the string variable<\/p>\n<p style=\"font-family:monospace;font-size:110%\">var strng_ex=&#8221;this_example_string&#8221;;<\/p>\n<p>The function substr(4,5) returns 5 characters from the string, starting at the fourth position (which is _, since the first position is 0):<\/p>\n<p><span style=\"font-family:monospace;font-size:110%\">strng_ex.substr(4,5)<\/span> has value <span style=\"font-family:monospace;font-size:110%\">_exam<\/span><\/p>\n<p>The function substring(4,5) returns a sequence of characters from the string, starting at position 4, then ending before position 5.  Therefore, the value of <\/p>\n<p><span style=\"font-family:monospace;font-size:110%\">strng_ex.substring(4,5)<\/span> is just<span style=\"font-family:monospace;font-size:110%\"> _<\/span><\/p>\n<p>HTH:)<\/p>\n<p>Source:<\/p>\n<p><a href=\"http:\/\/www.w3schools.com\/jsref\/jsref_obj_string.asp\">www.w3schools.com<\/a><\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor describes the difference between substr() and substring() Let&#8217;s imagine the string variable var strng_ex=&#8221;this_example_string&#8221;; The function substr(4,5) returns 5 characters from the string, starting at the fourth position (which is _, since the first position is 0): strng_ex.substr(4,5) &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/javascript-string-functions-substr-vs-substring\/\"> <span class=\"screen-reader-text\">JavaScript:  string functions:  substr() vs substring()<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1745],"tags":[2087],"class_list":["post-19411","post","type-post","status-publish","format-standard","hentry","category-javascript-computer-science","tag-substring-vs-substr"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/19411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=19411"}],"version-history":[{"count":13,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/19411\/revisions"}],"predecessor-version":[{"id":19424,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/19411\/revisions\/19424"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=19411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=19411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=19411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}