Last updated Sunday, November 25, 2001.
Given a string myString and a desired result width width, a center-justify function returns a new string that is length characters long containing myString padded as evenly as possible on either side with space characters. For example, a center-justify function, given the string "Rosetta Stone" (which contains 13 characters) and a desired result width of 23, should yield the result " Rosetta Stone " (5 spaces, followed by "Rosetta Stone", followed by 5 more spaces).
C# |
C#'s string class doesn't have a method for center-justification. I'll post some code soon. |
MFC's CString class (C++) |
MFC's CString class doesn't have a method for center-justification. I'll post some code soon. |
Python |
center functionfrom string import center center(myString, width) |
STL's string class (C++) |
MFC's string class doesn't have a method for center-justification. I'll post some code soon. |
RB |
RB doesn't have a built-in function for center-justification. I'll post some code soon. |
VB 6 |
VB 6 doesn't have a built-in function for center-justification. I'll post some code soon. |
VB .NET |
VB .NET doesn't have a built-in function for center-justification. I'll post some code soon. |
Given a string myString and a desired result width width, a left-justify function returns a new string that is length characters long containing the given string padded on the right with space characters. For example, a left-justify function, given the string "Rosetta Stone" (which contains 13 characters) and a desired result width of 23, should yield the result "Rosetta Stone " ("Rosetta Stone" followed by 10 spaces).
C# |
PadRight methodmyString.PadRight(width) |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
ljust functionfrom string import ljust ljust(myString, width) |
STL's string class (C++) |
TODO: Fill this in. |
RB |
Use custom function: LeftJustifyfunction LeftJustify(myString
as string, width as integer) as string |
VB 6 |
Use custom function: LeftJustifyfunction LeftJustify(myString
as string, width as integer) as string |
VB .NET |
PadRight methodmyString.PadRight(width)
LSet functionLSet(myString, width) |
Given a string myString and a desired result width width, a right-justify function returns a new string that is length characters long containing the given string padded on the left with space characters For example, a right-justify function, given the string "Rosetta Stone" (which contains 13 characters) and a desired result width of 23, should yield the result " Rosetta Stone" (10 spaces followed by "Rosetta Stone").
C# |
PadLeft methodmyString.PadLeft(width) |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
ljust functionfrom string import rjust rjust(myString, width) |
STL's string class (C++) |
TODO: Fill this in. |
RB |
Use custom function: RightJustifyfunction RightJustify(myString
as string, width as integer) as string |
VB 6 |
Use custom function: RightJustifyfunction RightJustify(myString
as string, width as integer) as string |
VB .NET |
PadRight methodmyString.PadRight(width)
RSet functionRSet(myString, width) |
Given an array of strings myArray (or in Python, a list of strings myList) and a separator character separator, an array/list-to-string function returns a string made of all the strings in myArray, separated by the separator. For example, consider the array (or list) illustrated by the table below:
element | string |
0 | Welcome |
1 | to |
2 | the |
3 | Rosetta |
4 | Stone |
This array, if provided with " " (a single space character) as the separator character to the array/list-to-string function, should return the string "Welcome to the Rosetta Stone".
C# |
Join methodString.Join(separator, myArray) |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
join / joinfields functionsjoin(myList[, separator]) joinfields(myList[, separator]) myList can be either a list or a tuple. If separator is not provided, the space character is used by default. join and joinfields now do the same thing. In the past, these functions took different numbers of arguments. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
TODO: Fill this in. |
VB 6 |
Join functionJoin(myArray[, separator]) |
VB .NET |
Join methodString.Join(separator, myArray)
Join functionJoin(myArray[, separator]) |
Given a string myString and one or more separator characters, an string-to-array/list function returns an array of strings derived from substrings of myString delimited by the separator characters. For example, given the string "Welcome to the Rosetta Stone". The string, if provided with " " (a single space) as the separator character, should yield an array illustrated by the table below.
element | string |
0 | Welcome |
1 | to |
2 | the |
3 | Rosetta |
4 | Stone |
C# |
Split methodmyString.Split([separatorArray]) |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
split / splitfields functionssplit(myString[, separator[, maxsplit]]) splitfields(myString[, separator[, maxsplit]]) split() and splitfields() now do the same thing. In the past, these functions took different numbers of arguments. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
No equivalent. |
VB6 |
Split functionSplit(myString [, separator [, count[, compare]]]) |
VB .NET |
Split methodmyString.Split([separatorArray])
Split functionSplit(myString [, separator [, count[, compare]]]) |
Given a string myString, a lowercase conversion function returns a new string containing the myString, with all alphabetical characters converted to lowercase. For example, given the string "The ROSETTA Stone", it should return "the rosetta stone".
C# |
ToLowermyString.ToLower() |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
lowerfrom string import lower lower(myString) Returns a string containing the contents of myString, with all uppercase characters converted to lowercase. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
lowercaselowercase(myString) Returns a string containing the contents of myString, with all uppercase characters converted to lowercase. |
VB 6 |
LCase / LCase$LCase(myString) LCase$(myString) LCase returns a variant (string) containing the contents of myString, with all uppercase characters converted to uppercase. LCase$ does the same thing as LCase, except that it returns a string value instead of a string value contained within a variant.
StrConvStrConv(myString, vbLowerCase) StrConv is a general-purpose string conversion function that can be used to convert to lowercase, among other things. vbLowerCase is a pre-defined constant whose value is 2. But really, why use this function when you've got LCase or LCase$, which are more readable and take only one argument? |
VB .NET |
ToLowermyString.ToLower()
LCase / LCase$LCase(myString) LCase$(myString) LCase returns a variant (string) containing the contents of myString, with all uppercase characters converted to uppercase. LCase$ does the same thing as LCase, except that it returns a string value instead of a string value contained within a variant.
StrConvStrConv(myString, VbStrConv.LowerCase) StrConv is a general-purpose string conversion function that can be used to convert to uppercase, among other things. VbStrConv.LowerCase is a pre-defined constant. But really, why use this function when you've got ToLower, which is more readable, standard across all CLR langauges and takes only one argument? |
Given a string myString, a "convert first letter of each word to uppercase" function (also called a "propercase" or "capitalize" function) returns a new string containing myString, with the first characters in each word converted to uppercase, if applicable. For example, given the string "the rosetta stone", it should return "The Rosetta Stone".
C# |
|
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
capwords functionfrom string import capwords capwords(myString) capwords replaces runs of whitespace characters with a single space and removes leading and trailing whitespace. It does so because it performs the capitalization by splitting myString into words using split, capitalizing each word using capitalize, and then joining the capitalized words using join. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
Titlecase functionTitlecase(phrase as String) Note that the only valid word separator for the Titlecase function is the space (character code 32). A word preceded by a TAB (character code 9) or RETURN (character code 13) will have all its characters converted to lower case, but will not be properly capitalised. If the TAB and RETURN characters were valid word separators, the Titlecase function would be considerably more useful, especially for long entries in EditField and StaticText controls. |
VB 6 |
StrConv functionStrConv(myString, vbProperCase) Returns a string in which all letter characters at the start of each word are converted to uppercase. Valid word separators (and their character codes) are:
|
VB .NET |
StrConv functionStrConv(myString, VbStrConv.ProperCase) Returns a string in which all letter characters at the start of each word are converted to uppercase. Valid word separators (and their character codes) are:
|
Given a string myString, an uppercase conversion function returns a new string containing myString, with all alphabetical characters converted to uppercase. For example, given the string "The Rosetta Stone", it should return "THE ROSETTA STONE".
C# |
ToUpper methodmyString.ToUpper() |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
upper functionfrom string import upper upper(myString) Returns a string containing the contents of myString, with all lowercase characters converted to uppercase. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
Uppercase functionUppercase(myString) Returns a string containing the contents of myString, with all lowercase characters converted to uppercase. |
VB 6 |
UCase / UCase$ functionsUCase(myString) UCase$(myString) UCase returns a variant (string) containing the contents of myString, with all lowercase characters converted to uppercase. UCase$ does the same thing as UCase, except that it returns a string value instead of a string value contained withina variant.
StrConv functionStrConv(myString, vbUpperCase) StrConv is a general-purpose string conversion function that can be used to convert to uppercase, among other things. vbUpperCase is a pre-defined constant whose value is 1. But really, why use this function when you've got UCase or UCase$, which are more readable and take only one argument? |
VB .NET |
ToUpper methodmyString.ToUpper()
UCase / UCase$ functionsUCase(myString) UCase$(myString)
StrConv functionStrConv(myString, VbStrConv.UpperCase) StrConv is a general-purpose string conversion function that can be used to convert to uppercase, among other things. VbStrConv.UpperCase is a pre-defined constant. But really, why use this function when you've got ToUpper, which is more readable, standard across all CLR langauges and take only one argument? |
Given two strings string1 and string2, a string comparison function returns an integer value that indicates the relationship between the two strings as shown below:
relationship
between string1 and string2 |
value returned by function |
string1 < string2 | negative |
string1 = string2 | 0 |
string1 > string2 | positive |
C# |
Compare methodString.Compare(string1, string2[, ignoreCase[, culture]]) Compare is case-sensitive by default. Case-sensitivity can be set through the optional boolean parameter ignoreCase; set it to false for a case-insensitive comparison or true for a case-sensitive one. The optional parameter culture (a CultureInfo object) is used when making string comparisons using non-English languages. |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
cmp(string1, string2) cmp is case-sensitive. To make it case-insensitive, use one of the case conversion functions -- either upper or lower will do -- to convert both string1 and string2. Here's how you encapsulate this as a function: def noCaseCmp(string1,
string2): |
STL's string class (C++) |
TODO: Fill this in. |
RB |
StrComp functionStrComp(string1 , string2, mode) Case-sensitivity can be set through the integer parameter mode; set it to 0 for a case-sensitive comparison or 1 for a case-insensitive one. |
VB |
StrComp functionStrComp(string1, string2[, mode]) Case-sensitivity can be set through the integer parameter mode; set it to 0 (or the built-in contsant vbBinaryCompare) for a case-sensitive comparison or 1 (or the built-in constant vbTextCompare) for a case-insensitive one. |
VB .NET |
Compare methodString.Compare(string1, string2[, ignoreCase[, culture]]) Compare is case-sensitive. For a case-insensitive comparison, set the optional parameter ignoreCase (a boolean) to false. The optional parameter culture (a CultureInfo object) is used when making string comparisons using non-English languages.
StrComp functionStrComp(string1, string2[, mode]) Case-sensitivity can be set through the parameter mode; set it to CompareMethod.Binary for a case-sensitive comparison orCompareMethod.Text for a case-insensitive one. |
Given two or more strings, a concatenation function returns a new string made up of the given strings joined together in the order in which they were given. For example, given the strings "The", "Rosetta" and "Stone" in that order, it should return "TheRosettaStone".
C# |
+ operatorstring1 + string2
Concat functionString.Concat(string1, string2[, string3[, string4]])
+= operatorstring1 += string2 Appends the contents of string2 to string1.
|
MFC's CString class (C++) |
+ operatorstring1 + string2
+= operatorstring1 += string2 Appends the contents of string2 to string1.
|
Python |
+ operatorstring1 + string2
+= operatorstring1 += string2 Appends the contents of string2 to string1.
|
STL's string class (C++) |
+ operatorstring1 + string2
+= operatorstring1 += string2 Appends the contents of string2 to string1.
|
RB |
+ operatorstring1 + string2
|
VB 6 |
& and + operatorsstring1 & string2 string1 + string2 Although both & and + are string concatenation operators, & is the preferred one since there's no ambiguity, especially in the case of attempting to concatenate two string values contained in variants. |
VB .NET |
+ operatorstring1 + string2
Concat functionString.Concat(string1, string2[, string3[, string4]])
|
Given a string myString, a start position start, and a length length, a "delete substring from a string" function returns a new string contaning myString with the substring of length length starting at position start removed. For example, given the string "The Rosetta Stone", a starting position of 4 (assuming the first position is 0) and a length of 7, it returns the string "The Stone".
C# |
Remove methodmyString.Remove(start, length) |
|
|
Python |
TODO: Fill this in. |
STL's string class (C++) |
myString.erase(start, length) Removes length characters from myString, starting at position start. |
RB |
TODO: Fill this in. |
VB 6 |
|
VB .NET |
Remove methodmyString.Remove(start, length) |
C# | |
MFC's CString class (C++) | TODO: Fill this in. |
Python | TODO: Fill this in. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
Returns a string. This string is the nth substring (where n is field number) of string separated by separator character. The first field is numbered 1, not 0. This is better illustrated by an example NthField ("First*Second*Third", "*", 2) would return "Second". This function, and its partner, CountFields, probably have dozens of data-juggling uses. |
VB |
No equivalent. Here's how you recreate RB's NthField method in VB6. This function uses the Split function, which is new to VB6.
|
C# |
|
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
TODO: Fill this in. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
Returns an integer denoting the number of fields in a string, which are separated by separator character. This is better illustrated by an example CountFields ("First*Second*Third") would return 3. This function, and its partner, NthField, probably have dozens of data-juggling uses. |
VB |
Here's how you recreate RB's CountFields method in VB6. This function uses the Split function, which is new to VB6.
|
Given a string myString and a string searchString to search for within myString, a "find first occurrence" function returns the character position of the first occurence of the searchString within the myString if it can be found, or some sentinel value (usually -1) if it can't. For example, given the string "The Rosetta Stone" and the search string "Rosetta", it should return the value 4 (assuming the first character position is considered to be 0. This is the case for all Rosetta Stone languages except VB 6, where the first character position in considered to be 1. For VB 6, the function should return 5).
C# |
IndexOf methodmyString.IndexOf(searchSubstring)
|
MFC's CString class (C++) | TODO: Fill this in. |
Python |
find functionfrom string import find find(myString, searchSubstring[, start[, end]]) Returns an integer containing the lowest index in myString where searchSubstring can be found, or -1 if searchSubstring is not contained within myString. If start is provided, the search for searchSubstring is limited to the slice beginning with start. If end is provided, the search for searchSubstring is limited to the slice ending with end.
index functionfrom string import index index(myString, searchSubstring[, start[, end]]) Like find(), except that it raises a ValueError if searchSubstring is not contained within myString.
rfind functionfrom string import rfind rfind(myString, searchSubstring[, start[, end]]) Like find(), except that it finds the highest index (that is, it starts search from the rightmost end of myString).
rindex functionfrom string import rindex rindex(myString, searchSubstring[, start[, end]]) Like rfind(), except that it raises a ValueError if searchSubstring is not contained within myString. |
STL's string class (C++) |
find methodmyString.find(searchSubstring[, start]) Searches myString for the first occurrence of searchSubstring (which can either be a string or char) starting at start (if start is omitted, the search starts at the beginning of the string). If searchSubstring is found, it returns the position of the first character in myString where the match occurs. If not, it returns the value string::npos.
rfind methodmyString.rfind(searchSubstring[, start]) Like find(), except the search starts at the end of myString and proceeds from right to left. |
RB |
InStr functionInStr([start as Integer], phrase as String, searchString as String)
InStrB functionInStrB([start as Integer], phrase as String, searchString as String) Instr returns an integer specifying the character position of the first occurrence of searchstring in string. The first character position of a string is 1, not 0. InStr returns 0 if string or searchstring is zero-length, searchstring is not found or start is past any occurrence of searchstring. This function is case-insensitive. |
VB 6 |
InStr functionInStr([start as number], phrase as String, searchstring as String [, compare as integer]) Instr returns a variant of subtype long specifying the character position of the first occurrence of searchstring in string. The first character position of a string is 1, not 0. InStr returns 0 if string is zero-length, searchstring is not found or start is past any occurrence of searchstring. InStr returns Null if either string or searchstring are Null. InStr returns start if searchstring is zero-length. start is an optional argument that specifies the character position where searching for substring in string should begin. The default is 1, referring to the first character in string. compare is an optional argument that specifies the type of string comparison used. The default value of 0 (or the built-in constant vbBinaryCompare) means that the comparison is binary that is, case-sensitive. A value of 1 (or the built-in constant vbTextCompare) means that the comparison is textual and hence case-insensitive. A value of 2 (or the built-in constant vbDatabaseCompare) is used for VBA in Microsoft Access only (see the VB documentation). If compare is omitted, the Option Compare setting determines the comparison type.
InStrB functionInStrB([start as number], phrase as String, searchstring as String [, compare as integer]) InStrB works similarly to InStr, except that it returns byte position instead of character positition.
InStrRev functionInStrRev(phrase as String, searchstring as String[, start as Integer[, compare as Integer]]) InStrRev is similar to InStr, except that its search is in the reverse direction (hence the name). InStrRevs search starts with the last character and proceeds towards the first. There are two other differences:
VB and VBA in a Nutshell has this to say about InStrRev: "The usefulness of a function that looks backward through a string for the occurrence of another string isnt immediately apparent. (p. 385)". However, it was apparent to Michael Loader, who reminded me vial e-mail that InStrRev can be used to find the last directory slash in a file path or last delimiter in a delimited string. VB6 has introduced some new string functions that can also be used for similar purposes. |
VB .NET |
IndexOf methodmyString.IndexOf(searchSubstring)
InStr functionInStr([start as number], phrase as String, searchstring as String [, compare as integer])
InStrRev functionInStrRev(phrase as String, searchstring as String[, start as Integer[, compare as Integer]]) InStrRev is similar to InStr, except that its search is in the reverse direction (hence the name). InStrRevs search starts with the last character and proceeds towards the first. There are two other differences:
VB and VBA in a Nutshell has this to say about InStrRev: "The usefulness of a function that looks backward through a string for the occurrence of another string isnt immediately apparent. (p. 385)". However, it was apparent to Michael Loader, who reminded me vial e-mail that InStrRev can be used to find the last directory slash in a file path or last delimiter in a delimited string. VB6 has introduced some new string functions that can also be used for similar purposes. |
Given a string myString, a start position start and a string insertString to insert into myString, an insert function returns a new string containing myString with insertString inserted into it at position start. For example, given the string "The Stone", a start position of 4 and an insertion string " Rosetta" (note the space at the start), it returns "The Rosetta Stone".
C# |
Insert methodmyString.Insert(start, insertString) |
|
|
Python |
TODO: Fill this in. |
STL's string class (C++) |
insert methodmyString.insert(start, insertString) |
RB |
TODO: Fill this in. |
VB 6 |
|
VB .NET |
Insert methodmyString.Insert(start, insertString) |
Given a string myString, a length function should return an integer value containing the number of characters in myString. For example, given the string "Rosetta Stone", the function should return 13.
C# |
Length propertymyString.Length |
MFC's CString class (C++) |
GetLength methodmyString.GetLength() Returns an integer containing the number of characters in myString. |
Python |
len functionlen(myString) Returns an integer containing the number of characters in myString. |
STL's string class (C++) |
size methodmyString.size()
length methodmyString.length() Both methods return a value of type string::size_type containing the number of characters in myString. |
RB |
len functionlen(myString) Returns an integer containing the number of characters in myString.
lenB functionlenB(myString) Returns an integer containing the number of bytes in myString. |
VB 6 |
Len functionLen(myString) Returns a long containing the number of characters in myString.
LenB functionLenB(myString) Returns a long containing the number of bytes in myString. |
VB .NET |
Length propertymyString.Length
Len functionLen(myString) Returns an integer containing the number of characters in myString. |
Given a character myCharacter and a number repetitions, a "repeating characters in a string" function return a string of length repetitions made up entirely of myCharacter characters. For example, given the character '*' and a value of 5, it would return the string "*****".
C# |
Use custom function: RepeatedCharactersC#'s string class doesn't have a method for creating a string of repeated characters. Use the function below (note that it's been declared as static -- you'll probably want to put it in a string utility class). public static string
RepeatedCharacters(char myCharacter, int repetitions) |
Java |
TODO: Fill this in. |
Python |
TODO: Fill this in. |
RB |
Use custom function: RepeatedCharactersRB doesn't have a built-in function for creating a string of repeated characters. Use the function below: Public Function RepeatedCharacters(myCharacter
as string, repetitions as integer) as String |
VB 6 |
String / String$ functionsString(value as number, character as String) String$(value as number, character as String) String returns a variant (string) made up of number occurences of character in a row. String$ does the same thing as String, except that it returns a string value instead of a string value contained within a variant.
Space / Space$ functionsSpace(value as number) Space$(value as number) Space returns a variant (string) made up of number occurences of space characters in a row. Space$ does the same thing as Space, except that it returns a string value instead of a string value contained within a variant. |
VB .NET |
Use custom function: RepeatedCharactersVB's string class doesn't have a method for creating a string of repeated characters, nor is there a built-in string function for creating a string made of repeated characters other than spaces. Use the function below. Public Function
RepeatedCharacters(myCharacter as Char, repetitions as Integer) as String
|
Given a string myString, a reverse string function should return a new string made of up the characters in myString in reverse order. For example, given the string "Rosetta Stone", it should return "enotS attesoR".
C# |
ReverseString methodC#'s string class doesn't have a method for reversing strings. Use the function below (note that it's been declared as static -- you'll probably want to put it in a string utility class). public static string
ReverseString(string theString) |
Java |
TODO: Fill this in. |
Python |
ReverseString functionPython doesn't have a built-in function for reversing strings, nor is there one in the string module. Use the function below. def ReverseString(theString): |
RB |
StrReverse functionRB doesn't have a built-in function for reversing strings. Use the function below. Public Function ReverseString(s as String) as String
End Function |
VB 6 |
StrReverse functionStrReverse(myString) StrReverse reverses the order of characters in a string. |
VB .NET |
StrReverse functionStrReverse(myString) StrReverse reverses the order of characters in a string. |
Given a string myString, a string searchString to search for within myString, and a replacement string replacementString, a search and replace function returns a new string made up of myString with replacementString substituting for all occurrences of searchString. For example, given the string "This is the Rosetta Stone", the search string "is" and the replacement string "at", it should return "That at the Rosetta Stone".
C# |
Replace methodmyString.Replace(searchString, replacementString)
|
Python |
replace functionreplace(myString, searchString, replacementString [, maxsplit]) |
RB |
ReplaceAll functionReplaceAll(myString, searchString, replacementString) ReplaceAll is similar to Replace, except that all occurences of oldsubstring are replaced with newsubstring. If oldsubstring is the empty string (""), ReplaceAll returns an unchanged copy of string. If newsubstring is the empty string, ReplaceAll returns a copy of string with all occurrences of oldsubstring removed. |
VB 6 |
Replace functionReplace(myString, searchString, replacementString) If oldsubstring is the empty string (""), Replace returns an unchanged copy of myString. If newsubstring is the empty string, Replace returns a copy of string with one or more occurrences of oldsubstring removed. |
VB .NET |
Replace methodmyString.Replace(searchString, replacementString)
Replace functionReplace(myString, searchString, replacementString) |
There are two ways a substring function can work:
C# |
Substring methodmyString.Substring(start[, length]) |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
Use slice notationmystring[start:end] Returns a string containing the slice defined by [start:end]. Remember that slice positions are defined not by character positions, but the "spaces between", with positon 0 being before the first character in the string, position 1 being after the first, position 2 after the second, and so on. For example, the following code: z = "Hello World" returns "ll" since the start position, 2, is between the e and l in "Hello" and the end position, 4, is between the l and o in "Hello". |
STL's string class (C++) |
substr methodmyString.substr(start, length) Returns a string created by copying length characters from myString starting at positon start. Both start and length are integers. Note than position 0 denotes the first character in the string. If start + length is greater than myString.size(), the resulting string contains all the characters starting from position start to the end of the myString. The result is undefined if start is greater than myString.size(). |
RB |
Mid functionMid(myString, start [,length]) Mid returns a string containing length characters from the middle of string, starting with character start. The first character position of a string is 1, not 0. If length is not specified, then Mid returns the rightmost portion of the string, starting at character start (it essentially becomes the Right function).
MidB functionMidB(myString, start [,length]) Like Mid, except that the length parameter is expressed in bytes, not characters. |
VB |
Mid / Mid$ functionsMid(myString, start [,length]) Mid$(myString, start [,length]) Returns a variant (string) containing length characters from the middle of string, starting with character start. The first character position of a string is 1, not 0. If length is not specified, then Mid returns the rightmost portion of the string, starting at character start (it essentially becomes the Right function). Does the same thing as Mid, except that it returns a string value instead of a string value contained within a variant. Most texts on VB recommend the use of Mid$ over Mid, since it returns a string instead of a variant (theoretically yielding better performance and using less memory). |
VB .NET |
Substring methodmyString.Substring(start[, length])
Mid functionMid(myString, start [,length]) |
Given a string myString and a length length, a left substring function should return a new string made up of the leftmost length characters of myString. For example, given the string "The Rosetta Stone" and length of 3, it should return the string "The".
C# |
|
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
myString[0:length]
Python doesn't have a built-in function for extracting the left portion of a string, but getting the [0:length] slice will give you the length leftmost characters of myString. |
STL's string class (C++) |
Use the substr() method: myString.substr(0, length) Returns a string containing the length leftmost characters of myString. |
RB |
Left(myString, length) LeftB(myString, length) Returns a string containing the length leftmost characters of myString. |
VB |
Left(myString, length) Left$(myString, length) Left returns a variant (string) containing the length leftmost characters of myString. Left$ does the same thing as Left, except that it returns a string value instead of a string value contained within a variant. Most texts on VB recommend the use of Left$ over Left, since it returns a string instead of a variant (theoretically yielding better performance and using less memory). |
Given a string myString and a length length, a right substring function should return a new string made up of the rightmost length characters of myString. For example, given the string "The Rosetta Stone" and length of 3, it should return the string "one".
C# |
|
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
myString[len(myString)
- length:]
Python doesn't have a built-in function for extracting the right portion of a string, but getting the [len(myString) - length:] slice will give you the length rightmost characters of myString. |
STL's string class (C++) |
Use the substr() and size() methods: myString.substr(mystring.size() - length, length) Returns a string containing the length rightnost characters of myString. |
RB |
Right(myString, length) RightB(myString, length) Returns a string containing the length rightmost characters of myString. |
VB |
Right(myString, length) Right$(myString, length) Right returns a variant (string) containing the length rightmost characters of myString. Right$ does the same thing as Right, except that it returns a string value instead of a string value contained withina variant. Most texts on VB recommend the use of Right$ over Right, since it returns a string instead of a variant (theoretically yielding better performance and using less memory). |
Given a string myString, a "remove leading whitespace characters" function returns a new string made up of myString with any leading whitespace characters removed. For example, given the string " The Rosetta Stone ", it should return the string "The Rosetta Stone ".
C# |
TrimStart methodmyString.TrimStart() |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
lstrip functionfrom string import lstrip lstrip(myString) Returns a string containing a copy of myString without any leading whitespace characters. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
LTrim functionLTrim(myString) Returns a string containing a copy of myString without any leading spaces. |
VB 6 |
LTrim / LTrim$ functionLTrim(myString) LTrim$(myString) LTrim returns a variant (string) containing a copy of myString without any leading spaces. LTrim$ does the same thing as LTrim, except that it returns a string value instead of a string value contained within a variant. |
VB .NET |
TrimStart methodmyString.TrimStart()
LTrim functionLTrim(myString) LTrim returns a variant string containing a copy of myString without any leading spaces. |
Given a string myString, a "remove leading and trailing whitespace characters" function returns a new string made up of myString with any leading and trailing whitespace characters removed. For example, given the string " The Rosetta Stone ", it should return the string "The Rosetta Stone".
C# |
Trim methodmyString.Trim() |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
strip functionfrom string import strip strip(myString) Returns a string containing a copy of myString without any leading or trailing whitespace characters. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
Trim functionTrim(myString) Returns a string containing a copy of myString without any leading or trailing spaces. |
VB 6 |
Trim / Trim$ methodsTrim(myString) Trim$(myString) Trim returns a variant (string) containing a copy of myString without any leading or trailing spaces. Trim$ does the same thing as Trim, except that it returns a string value instead of a string value contained within a variant. |
VB .NET |
Trim methodmyString.Trim()
Trim functionTrim(myString)
|
Given a string myString, a "remove trailing whitespace characters" function returns a new string made up of myString with any trailing whitespace characters removed. For example, given the string " The Rosetta Stone ", it should return the string " The Rosetta Stone".
C# |
TrimEnd methodmyString.TrimEnd() |
MFC's CString class (C++) |
TODO: Fill this in. |
Python |
rstrip functionfrom string import rstrip rstrip(myString) Returns a string containing a copy of myString without any trailing whitespace characters. |
STL's string class (C++) |
TODO: Fill this in. |
RB |
RTrim functionRTrim(myString) Returns string containing a copy of myString without any trailing spaces. |
VB 6 |
RTrim / RTrim$ functionsRTrim(myString) RTrim$(myString) RTrim returns a variant (string) containing a copy of myString without any trailing spaces. RTrim$ does the same thing as RTrim, except that it returns a string value instead of a string value contained within a variant. |
VB .NET |
TrimEnd methodmyString.TrimEnd()
RTrim functionRTrim(myString) RTrim returns a string containing a copy of myString without any trailing spaces.
|