120 likes | 281 Views
Strings!. Comp 101. What is a String?. Basically, a sequence of characters Character? Like… a letter Or a number Or even blank space. What is a String?. Anything can be interpreted as a string regardless of format In an expression (formula) string must be inside double quotes!
E N D
Strings! Comp 101
What is a String? • Basically, a sequence of characters • Character? • Like… a letter • Or a number • Or even blank space
What is a String? • Anything can be interpreted as a string regardless of format • In an expression (formula) string must be inside double quotes! • “this is a string” and this is not a string. • Remember to beware cut and paste
Referencing characters Each character has a position
Substring • A substring is also a String • A substring is a part of another string • “cake” is a substring of “birthday cake” • so are “day”, “thd”, and “y cake” • “they” is not, neither is “hello” or “dude”
Selecting substrings LEFT – leftmost characters RIGHT – rightmost characters MID – characters in the middle Exercise
Length: LEN Finds the length of a String One of the most important functions Relationship between length and position?
Processing Strings • Operations on Strings such as: • Searching • Replacing • Concatenating • Converting
How? • Click the function button • Select Text • They actually mean String, but whatever • List of handy functions and other goodies
Searching • Find – case sensitive search • Cake ≠ cake • Search – non-case sensitive search • Cake = cake • Example: • Look for UNC
Concatenating • Huh? • It means combining two or more things into one thing • & Anything can be concatenated • “awe” & “some” = “awesome” • Whitespace only matters inside quotes • “a”&“b” same as “a” & “b” • “a ” & “b” NOT the same as “a” & “b”
CONCATENATE Function • Also a function called concatenate • Same thing as & • Can use either • Same as SUM or + • Exercise: • Concatenate two names and a blank or comma