Jump to content

Please make a regex for this string please!


gosu
 Share

Recommended Posts

05-01-12 16:19:14 Connection accepted to 12.34.567.890

This is the line I want to parse. I want to get everything in this line behind

05-01-12 16:19:14 Connection accepted to

The date is never the same and always changes like the ip behind "to ".

Please give me a regex.

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Link to comment
Share on other sites

Is this line being parsed from a text file or a screen scrape.... either way, it makes no difference....

You could use a stringmid to pull that out.

Screen Scrape Example:

$tem = StringStripWS(ClipGet(), 8)
$tem2 = StringInStr($tem, "Connectionacceptedto")
$prompt = StringMid($tem, $tem2, 20); or change "20" to "36" to capture the IP as well
$ip = StringRight(StringMid($tem, $tem2, 36),16)

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Is this line being parsed from a text file or a screen scrape.... either way, it makes no difference....

You could use a stringmid to pull that out. 

Screen Scrape Example:

$tem = StringStripWS(ClipGet(), 8)
$tem2 = StringInStr($tem, "Connectionacceptedto")
$prompt = StringMid($tem, $tem2, 20); or change "20" to "36" to capture the IP as well
$ip = StringRight(StringMid($tem, $tem2, 36),16)

<{POST_SNAPBACK}>

Thanks.

Hm, I thought RegEx was the better soulutin, but this seems to be better. Thanks.

: Hm, does anybody have a working RegEx? I like small code better.

Edited by gosu

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Link to comment
Share on other sites

As requested:

$Regex = "(\d+.\d+.\d+.\d+)"
$nul = RegExp($string, $Regex, "clientip")

The first result is in $clientip[0]

(This code runs up to autoit-v3.0.103.exe), the latest version would be something like

$clientip=StringRegExp($string,$regexp)

(btw, your given "IP" would be a valid ip to this "parser" although it is not;)

hth, Tys

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...