VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Extract substring from string between 2 specified strings, UPDATED Mar 30, 2002

Brian Battles WS1O  (15 Submissions)   String Manipulation   Visual Basic 3.0   Beginner   Wed 3rd February 2021

Extracts the contents of a "child" substring from a "parent" string between 2 additional specified substrings.
For example, if you called it like this:
GetStringBetween("Fourscore and seven years ago, our fathers", " and ", " our ")
It will return
"seven years ago,"

Inputs
"parent" string, string to begin after, optional string to end before, optional case sensitive flag

Assumes
Pass this function a string (strCompleteString), and it will return a substring consisting of everything between 2 other specified strings (ie, everything between strFirst and strLast) You can also optionally specify if it should be case sensitive (default is False) Example: GetStringBetween("Fourscore and seven years ago, our fathers", "and", "our") would return "seven years ago," Bonus: if you leave out the last string, you'll just get the word following the first word Example: GetStringBetween("Fourscore and seven years ago, our fathers", "and") would return "seven"

Returns
String

Side Effects
Not really a "side effect," more of a "bonus," if you pass in a space " " as the end string, you just get back the one full word after the first string

Rate Extract substring from string between 2 specified strings, UPDATED Mar 30, 2002 (4(4 Vote))
Extract substring from string between 2 specified strings, UPDATED Mar 30, 2002.bas

Extract substring from string between 2 specified strings, UPDATED Mar 30, 2002 Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters