String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

8
String String Manipulation Manipulation By By Felix Thompson, Jerzy Felix Thompson, Jerzy Griffiths Griffiths and and Joel Sutcliffe Joel Sutcliffe

Transcript of String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

Page 1: String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

String ManipulationString ManipulationBy By

Felix Thompson, Jerzy Griffiths Felix Thompson, Jerzy Griffiths andand

Joel SutcliffeJoel Sutcliffe

Page 2: String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

What is string manipulation?What is string manipulation?

String manipulation is interacting String manipulation is interacting with strings to read information from with strings to read information from them or limit what they can be.them or limit what they can be.

Page 3: String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

Reading data from a stringReading data from a string

Left – This reads a certain amount of Left – This reads a certain amount of characters in order going from left to characters in order going from left to rightright

Right– This reads a certain amount of Right– This reads a certain amount of characters in order going from right to characters in order going from right to leftleft

Mid - This reads a certain length of Mid - This reads a certain length of the string going from a set point for a the string going from a set point for a certain number of characterscertain number of characters

Page 4: String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

For exampleFor example

Text = ManipulationText = Manipulation Left(Text, 5) would come as ManipLeft(Text, 5) would come as Manip Right(Text, 6) would come as lationRight(Text, 6) would come as lation Mid(Text, 2 ,4) would come as nipuMid(Text, 2 ,4) would come as nipu

Page 5: String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

Describing a stringDescribing a string

Locate – this tells you where in a Locate – this tells you where in a string a certain character is.string a certain character is.

Length – this tells you the length of a Length – this tells you the length of a stringstring

Locate(Text, “p”) would come out as Locate(Text, “p”) would come out as 55

Len(Text) would come out as 12 Len(Text) would come out as 12

Page 6: String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

Character and ASCII valuesCharacter and ASCII values

Asc - This returns the ASCII value of a Asc - This returns the ASCII value of a single character.single character.

Chr – This returns the character of an Chr – This returns the character of an ASCII value.ASCII value.

Asc(“B”) would come out as 66Asc(“B”) would come out as 66 Chr(“66”) would come out as BChr(“66”) would come out as B

Page 7: String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

ReplaceReplace

Use this to replace a set of Use this to replace a set of characters to another set.characters to another set.

Text = hello worldText = hello world Replace(Text, “hello”, “goodbye”)Replace(Text, “hello”, “goodbye”) Text = goodbye worldText = goodbye world

Page 8: String Manipulation By Felix Thompson, Jerzy Griffiths and Joel Sutcliffe.

Comparing stringsComparing strings

When comparing strings it reads it as When comparing strings it reads it as its ASCII value for example A < a its ASCII value for example A < a because because

A = 65A = 65 a = 97a = 97 a < ab because it adds the value a < ab because it adds the value

together.together.