\n
<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
A string is a sequence of characters. You can access the characters one at a time with the bracket operator. <\/span><\/p>\nPer example, let’s declare a string variable called car<\/em> containing a sequence of characters forming the word mazda6<\/em>. <\/span><\/p>\n<\/p>\n<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
In this example I’m calling the character corresponding to the third value of index of characters. Remember that the index starts at 0, so the character 0 will be c, the character 1 a, the character 2 z and so on. <\/span><\/p>\nLen. <\/span><\/strong><\/p>\nThe function len is able to return the numbers of characters contained in a string. Example: <\/span><\/p>\n <\/p>\n<\/p>\n
<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
If you want to get the last character of a string you can try something like this: <\/span><\/p>\n<\/p>\n<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
Traversal. <\/span><\/strong><\/p>\nThe process of dealing one string character at time and doing something to it, is called traversal processing. <\/span><\/p>\nExample: <\/span><\/p>\n<\/p>\n<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
This prints individually each of the characters contained inside the car string. <\/span><\/p>\nSlices. <\/span><\/strong><\/p>\nSlices are segment of strings. Selecting slices of a certain strings is really easy. <\/span><\/p>\nExample: <\/span><\/p>\n<\/p>\n<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
The slice that I’m calling in this example is one going from the index 0 to the 4th<\/sup> index. Notice that using the 5 in the brackets means calling the previous character in the index. So the bracket works something like this [firstindex:lastindex+1].<\/span><\/p>\nBecause…<\/span><\/p>\n<\/p>\n<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
Immutability. <\/span><\/strong><\/p>\nStrings are immutable, that meaning that you are not able to change an existing string. The best thing you can do to deal with this is creating a new string that is a variation from the original. <\/span><\/p>\nExample, let’s call a new model ‘mazda3’:<\/span><\/p>\n<\/p>\n<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
You can appreciate that I’m calling the slice that contains the word ‘mazda’ and I’m adding a ‘3’ to the end, so I have a new string called new model containing the string ‘Mazda3’<\/strong><\/span><\/p>\nCounting. <\/span><\/strong><\/p>\nAlso, you can go a little forward and count the times that a character appears in a string. Let’s count how many times the ‘a’ appears in ‘Mazda6’.<\/span><\/p>\n<\/p>\n <\/p>\n
<\/p>\n
<\/p>\n
Normal
\n 0<\/p>\n
21<\/p>\n
false
\n false
\n false<\/p>\n
ES-MX
\n X-NONE
\n X-NONE<\/p>\n
<\/p>\n
<\/p>\n
\/* Style Definitions *\/
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
These are somes of the things that you can do with a string. Have fun \ud83d\ude00 <\/span><\/p>\n <\/p>\n
<\/p>\n
#Mastery<\/a>26<\/p>\n<\/div>\n Continue reading →<\/span><\/a><\/p>\n","protected":false},"author":104,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3,25],"tags":[186,243,287],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/13561"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/users\/104"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/comments?post=13561"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/13561\/revisions"}],"predecessor-version":[{"id":17540,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/13561\/revisions\/17540"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/media?parent=13561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/categories?post=13561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/tags?post=13561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}