Going nuts- Is there a Regex builder that actually BUILDS your RegEx from a highlight

simpleonline

Active member
Joined
Sep 13, 2011
Messages
33
Programming Experience
Beginner
I've been working straight since yesterday trying to get this to work. I'm a noob to RegEx and I've tested out about 5 different RegEx "builders" but each of them require you to navigate through the options to build the Regex...each of them has failed when I try to use them.

Is there an application out there free/paid where you select the line you want to grab and the RegEx is auto generated from that highlight rather than having to try to build the line of code?

What I want to grab is this line of code:

VB.NET:
<script type="text/javascript" src="hxxp://www.mysite.com/item103">

Of course this line changes since the items are always changing so I would only need to grab up to the "hxxp://www.mysite.com/

I can do this using the web browser control but I'm attempting to speed things up by using a webrequest.

Any ideas on the RegEx software or how to grab this exact line?

Thanks

EDIT: Might help if you see my code as well so here goes it:

VB.NET:
       Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(Textbox1.text)
        Dim response As System.Net.HttpWebResponse = request.GetResponse
        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
        Dim rssourcecode As String = sr.ReadToEnd

        '("src=([""'])(.*?)\1") 
        '<script type=""text/javascript"" src=""hxxp://www.mysite/item103"">
        Dim r As New System.Text.RegularExpressions.Regex("<script[\s\S]*?/script>")
        Dim matches As MatchCollection = r.Matches(rssourcecode)
        For Each itemcode As Match In matches
            TextBox1.Text = TextBox1.Text & itemcode.Value & vbNewLine
        Next

[/CODE]
 
There's basically no way that any automated tool can read a single line and generate the one and only regex that you want because there would be many others that would also apply to that one line. You would need to provide multiple examples at least. You might look at RegexMagic. I own a license but I've not really used it as it's not exactly intuitive, but then regex as a concept are complex and archaic.
 
Back
Top