Richard Kreidl
asked on
Check for string????
How would you use "instr" to check for a particular type of string?
I need to check strings like the following strings:
5555550129@archwireless.ne t555555013 9@archwire less.net
5555550129@archwireless.co m555555013 9@archwire less.net
that I need to separate like this:
5555550129@archwireless.ne t 5555550139@archwireless.ne t
5555550129@archwireless.co m 5555550139@archwireless.ne t
So, I somehow need to check if there is a "t" or a "c" followed by a number and then add a space bewteen the "t" or "c" and the number.
thanks
I need to check strings like the following strings:
5555550129@archwireless.ne
5555550129@archwireless.co
that I need to separate like this:
5555550129@archwireless.ne
5555550129@archwireless.co
So, I somehow need to check if there is a "t" or a "c" followed by a number and then add a space bewteen the "t" or "c" and the number.
thanks
ASKER
Sorry, I should have mentioned the string data is in a textbox and also archwireless is not a constant. It could be sprintpcs or other providers
ASKER
You can't convert a textbox to an array
Same thing just different input and a small change to the pattern allowing any domain.
Dim pattern As String = "(\d+@.+?\.(?:net|com))(\d +@.+?\.(?: net|com))"
TextBox1.Text = Regex.Replace(TextBox1.Tex t, pattern, "$1 $2")
Dim pattern As String = "(\d+@.+?\.(?:net|com))(\d
TextBox1.Text = Regex.Replace(TextBox1.Tex
The question did not say that the text string was in a text box.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry missed a space after the $1 below
Dim pattern As String = "(\d+@.+?\.(?:net|com))"
' Should be this
TextBox1.Text = Regex.Replace(TextBox1.Tex t, pattern, "$1 ")
Dim pattern As String = "(\d+@.+?\.(?:net|com))"
' Should be this
TextBox1.Text = Regex.Replace(TextBox1.Tex
This will do what you need.
Imports System.Text.RegularExpress
' Test Data
Dim input() As String = {"5555550129@archwireless.
"5555550129@archwireless.c
' The Regular Expression pattern to parse the input
Dim pattern As String = "(\d+@archwireless.(?:net|
Dim idx As Integer = 0
For Each email As String In input
' Parse the input
input(idx) = Regex.Replace(input(idx), pattern, "$1 $2")
idx += 1
Next
' Display Results
MessageBox.Show(input(0) & Environment.NewLine & input(1))
Fernando