|
-
Jul 23rd, 2012, 02:37 AM
#1
Thread Starter
Member
vb regex.replace help
Ok this is kind of a multi-part question.
First off I have a string that can be any one of the following
[@Flos'tok]
[@Flos'tok:Tharan Cedrax {493285583880192}]
[Infiltrator {1554550527885312}:111091844024]
Where "Flos'tok" and "Tharan Cedrax" and "Infiltrator" can be any of a billion possibilities.
I need to glean 3 different bits of info from them
I first need to get "Flos'tok" no matter which of the 3 strings are presented.
I know it's not possible if the [Infiltrator {1554550527885312}:111091844024]
is presented but that is not an issue since that string can only happen later so for the 1st question
IF [@Flos'tok:Tharan Cedrax {493285583880192}] is the string passed I need to Split "Flos'tok" and "Tharan Cedrax" and ignore anything else as in the "{493285583880192}"
So I can assign
Label1.text = "Flos'tok"
and
Label2.text = "Tharan Cedrax"
1st problem is there is a 50/50 chance the initial string will just be
[@Flos'tok]
Which then I just need to assign
Label1.text = "Flos'tok"
And when it finds
[@Flos'tok:Tharan Cedrax {493285583880192}]
Then just assign
Label2.text = "Tharan Cedrax"
Now Tharan Cedrax and Flos'tok can and will be any number of names, I'm just using them as an example
So my real 1st question is how to strip and remove the {} and anything in between
something like Dim StrValue as String = Regex.Replace(strArr(1), "{^}*", "")?
So after I get past all that I should have 2 populated labelx.text
using the info above it would be
Label1.text = "Flos'tok"
Label2.text = "Tharan Cedrax"
Label3.text = ""
So then I guess I could just use something like
Dim Checker1 = Label1.text
Dim Checker2 = Label2.text
If NOT Checker1.Contains(Label1.Text) OR NOT Checker2.Contains(Label2.Text) Then
'it didn't contain either so it is [Infiltrator {1554550527885312}:111091844024]
Label3.Text = "Infiltrator"
'without any of the {1554550527885312}:111091844024
End If
Does this make any sense?
I need a way to differentiate
[@Flos'tok]
[@Flos'tok:Tharan Cedrax {493285583880192}]
[Infiltrator {1554550527885312}:111091844024]
And get "Flos'tok" from "@Flos'tok:Tharan Cedrax {493285583880192}" and "Tharan Cedrax" from "@Flos'tok:Tharan Cedrax {493285583880192}"
and NOT include "{493285583880192} or "{1554550527885312}:111091844024" in either and if it's neither use the name provided. And assign each value to a Labelx.text
I know I can split Flos'tok:Tharan Cedrax to get Label1 and label 2 but it is not always there first, as many times as not it will just be Flos'tok first and then the next read will give me Flos'tok:Tharan Cedrax and the next read may be Infiltrator {1554550527885312}:111091844024
I hope this makes sense because it took forever to write 
I am a real newbie so please treat your response as such.
TIA
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|