Page 1 of 2

regex

Posted: Wed Jan 15, 2014 8:58 am
by Dummy1912
hello,

hope somebody can help me out it drives me goofy;

i need to make from (call: codenstuff) a url

even #CodenStuff send me to some regex websites but no idea why it don't work
Code: Select all
dim ss = New Regex("\b(?<call>[a-zA-Z_0-9.-]+\w+)\b")
Code: Select all
        s = ss.Replace(s, "<a href=""${call}"" title=""Call me"" "">Call ${call}'here only the name without call:</a>")
i write:
i have to call: codenstuff at once.

so i want it to looks like this
i have to Call codenstuff at once
so the url contains: call: codenstuff

anyone please cryer;

Re: regex

Posted: Wed Jan 15, 2014 9:30 am
by XTechVB
Try this Regex
Code: Select all
call:?\W\S*

Re: regex

Posted: Wed Jan 15, 2014 9:38 am
by Dummy1912
?? whats the complete regex? #XTechVB

i tried:
Code: Select all
New Regex("\b(?<call>\W\S*)\b")
but only showed call

Re: regex

Posted: Wed Jan 15, 2014 9:45 am
by XTechVB
Dummy1912 wrote:
?? whats the complete regex? #XTechVB

i tried:
Code: Select all
New Regex("\b(?<call>\W\S*)\b")
but only showed call
Just a basic example
Code: Select all
        Dim Rgx As Regex = New Regex("call:?\W\S*")
        For Each RgMatch As Match In Rgx.Matches(TextBox1.Text)
            MessageBox.Show(RgMatch.Value)
        Next

Re: regex

Posted: Wed Jan 15, 2014 9:51 am
by Dummy1912
can you make it work like my own example #XTechVB
because its all in 1 sub :)
so i don't need to use if s.contains("call") then

if you get me :)

Re: regex

Posted: Wed Jan 15, 2014 9:58 am
by Dummy1912
ok but still

i need to use
Code: Select all
s = ss.Replace(s, "<a href=""${call}"" title=""Call me"" "">Call ${call}'here only the name without call:</a>")

Re: regex

Posted: Wed Jan 15, 2014 10:38 am
by XTechVB
Well this example works fine
Code: Select all
        Dim Rgx As Regex = New Regex("call:?\W\S*")
        For Each RgMatch As Match In Rgx.Matches(TextBox1.Text)
            Dim FoundCall As String = RgMatch.Value.Substring(5, RgMatch.Value.Length - 5)
            TextBox1.Text = TextBox1.Text.Replace(RgMatch.Value, "<a href=" + """" + FoundCall + """" + " title=""Call me"" "">Call " + FoundCall + "</a>")
        Next

Re: regex

Posted: Wed Jan 15, 2014 10:52 am
by Dummy1912
#XTechVB

its not working :(

Re: regex

Posted: Wed Jan 15, 2014 10:59 am
by XTechVB
Dummy1912 wrote:
#XTechVB

its not working :(
I don't know what to tell you for me it works fine.
I'll send you the application.

Re: regex

Posted: Wed Jan 15, 2014 11:12 am
by Dummy1912
thanks for the demo works fine at some minus parts :)
if you can do what i PMed you
then ill try to see where my problem stuck :)