Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split string by a space

Tags:

string

vb6

I have one string that has two words in it:

Cat Dog

How can I split these up so I get:

Str1 = Cat and Str2 = Dog

Please note this is for VB6.

like image 589
user3258734 Avatar asked Jan 15 '15 23:01

user3258734


People also ask

How do you split a string by spaces?

To split a string by multiple spaces, call the split() method, passing it a regular expression, e.g. str. trim(). split(/\s+/) . The regular expression will split the string on one or more spaces and return an array containing the substrings.

How do you split a string by spaces in Python?

The split() method splits a string into a list. You can specify the separator, default separator is any whitespace. Note: When maxsplit is specified, the list will contain the specified number of elements plus one.

How do you split a string by a space and a comma?

To split a string by space or comma, pass the following regular expression to the split() method - /[, ]+/ . The method will split the string on each occurrence of a space or comma and return an array containing the substrings.

How do you split one or more spaces?

split() method to split a string by one or more spaces. The str. split() method splits the string into a list of substrings using a delimiter.


1 Answers

Use the Split function.

Dim output() As String
output = Split("Cat Dog", " ")

Would produce

output(0) = Cat
output(1) = Dog
like image 60
ecnepsnai Avatar answered Nov 14 '22 14:11

ecnepsnai