BP Forums
Working with Regex - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+---- Thread: Working with Regex (/showthread.php?tid=320)



Working with Regex - xolara - 02-24-2011

Hey ive been working on how to make a "lng" file for your application and ive kinda succeded

Here is the code play with it as much as you want <!-- sSmile --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="Smile" title="Smile" /><!-- sSmile -->
(IMPORTS)
Code:
Imports System.Text.RegularExpressions

(Textbox1.textchanged) (Hide it if you feel like it, it will still do its job <!-- sSmile --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="Smile" title="Smile" /><!-- sSmile --> )

Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim content As String = Replace(TextBox1.Text, Global.Microsoft.VisualBasic.ChrW(10), Nothing)
        Dim regex As New Regex("<language.*ButtonSend=""Name"".*ButtonName="".*""")
        Dim rbutton2 As New Regex("<language.*ButtonClear=""Name"".*ButtonName="".*""")
        '(Set.*buttonsend=""
        For Each m As Match In regex.Matches(content)
            Try
                Dim ButtonSend As String = m.Value.Split("""").GetValue(3)
                Dim ButtonClear As String = m.Value.Split("""").GetValue(7)
                Button1.Text = ButtonSend
                Button2.Text = ButtonClear
            Catch ex As Exception

            End Try

        Next
    End Sub

(Read config or lang file) I would set mine to Form load but you can allso make them able to change it so it will reload on a button or something
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Text = My.Computer.FileSystem.ReadAllText(My.Application.Info.DirectoryPath + "\Config.cfg")
    End Sub

[EDIT]
Download link to EXE to check it out and see that it is working fine <!-- sSmile --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="Smile" title="Smile" /><!-- sSmile -->
<!-- m --><a class="postlink" href="http://dl.dropbox.com/u/12582973/CFG.zip">http://dl.dropbox.com/u/12582973/CFG.zip</a><!-- m -->


Re: Working with Regex - brandonio21 - 02-24-2011

Wow, This is awesome. Might have to use this in my projects <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->

P.S - Make sure to extract if you download the .exe


Re: Working with Regex - xolara - 02-24-2011

dosnt matter it can allso read the .cfg file in the zip <!-- sSmile --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="Smile" title="Smile" /><!-- sSmile --> atleast it can at me ^^