I have a string similair to this inputted: a[1-3]bc
I want to split it into [1-3] and .
My current code is: Regex.Split(txtPwFormat.Text, "[\[0-9-\]]+")
It works like a charm in determining which pieces i don't want, and will output an array containing a, b and c.
So is there another method, one that is similar to preg_match_all in php, in vb.net? Or do I have to restructure my format?
I always use a deliminator, a comma for instance. e.g. a,b,c,d
I dno not see how I could work with simple delimeteres here. I need to be able to split a[1-3]bc like described in the first post
I'm not sure about your string structure, I don't understand the a ,b & c.
The way I understand it you want extract the vaues in brackets, if this is the case your initial string needs the format
you can accomplish this by using
If this isn't what you need try and be more precise about the input and output strings you require, exactly what do you want the values of your output array to be?
Last edited by Steve36445; 02-07-2009 at 08:37 AM.
The inputted string by the user, which can look like a[1-3]bc, or spamzblaat[1-2]omg does contain information i need in my program. I need both the text parts, and the number parts between brackets.
Please give an example of exactly what output you requie
Is it for instance you need two string arrays eg.
Last edited by Steve36445; 02-07-2009 at 09:02 AM.
That is indeed the output I want. (assuming you forgot to increase the index nrs of the first array.)
I'm trieng to make an adaptation of this php script (see attachment).
How big is the string to split? Are we talking kb,mb or what?
Can the input string be changed to be deliminated? It can be done without but it is easier if it is delimiated in the first place
Try this, add two listboxes to the form, leave the names as default-
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim input_string = "a[1-3]bc"
Dim text_array(10) As String
Dim bracket_array(10) As String
Dim split_array() As String
Dim text_array_counter As Int16
Dim bracket_array_counter As Int16
' First delininate the string
input_string = Replace(input_string, "[", ",[")
input_string = Replace(input_string, "]", "],")
MessageBox.Show("Deliminated string " + input_string)
'split into one array
split_array = Split(input_string, ",")
'put in their own array
For Each item As String In split_array
If InStr(item, "[") Then
bracket_array(bracket_array_counter) = item
bracket_array_counter = bracket_array_counter + 1
ListBox1.Items.Add(item) ' display the reults
text_array(text_array_counter) = item
text_array_counter = text_array_counter + 1
ListBox2.Items.Add(item) ' display the reults
Last edited by Steve36445; 02-07-2009 at 10:18 AM.
Your code is working, thnx alot for it!
It is not an option to let the input be delimetered, casue the user has to enter it, and they will have a hard time understanding how to brackets work by itself
By gsmmc in forum Database
Last Post: 10-02-2008, 01:48 PM
By SDSoftDev in forum .NET
Last Post: 07-17-2008, 08:16 AM
By dman in forum VB Classic
Last Post: 02-22-2008, 12:36 PM
By Tony Lintunen in forum .NET
Last Post: 02-04-2006, 05:20 PM
By Saurabh in forum dotnet.announcements
Last Post: 09-19-2001, 06:48 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center