Penguin
Diff: ManipulatingStrings
EditPageHistoryDiffInfoLikePages

Differences between version 2 and previous revision of ManipulatingStrings.

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Monday, December 11, 2006 12:33:56 pm by BenStaz Revert
Older page: version 1 Last edited on Monday, December 11, 2006 12:31:45 pm by BenStaz Revert
@@ -10,4 +10,12 @@
  
 *expr length test 
  
 Both will give you the correct length of 16. 
+  
+!How can I get a substring of a variable?  
+  
+Say the variable test contains the string "corndog" but we want just the "dog" part.  
+  
+echo ${test:4:3} will return just "dog"  
+  
+The 4 tells us the index of the char that will be the first char in the substring. The 3 tells us how many letters to add starting at the index.