Jump to content
Sign in to follow this  
gcue

parsing out data

Recommended Posts

gcue

hello world

i am trying to go through several files to collect screen name and nick name information.

so if a line within one of the files contains "AOL;Instant;Messenger",  it is a contact I want to pull

here's are a few sample lines:

 


U baleywash12::AOL;Instant;Messenger baleywash1,wash,wash

(baleywash1 = screen name, wash = nick name)

U tikellyjp2::AOL;Instant;Messenger tikellyjp,tim;kelly,tim;kelly

(tikellyjp = screen name, tim kelly = nick name)

U jegdk2::AOL;Instant;Messenger jegdk,

(jegdk = screen name and nick name)

 

I think this can all be done with stringregexp but I cant seem to get the syntax correct.

here's what i have so far:

#include <array.au3>
 
$msg_normal = 0
 
$file = "\\08-19-2013.txt"
 
$open = FileOpen($file, 0)
 
$data = FileRead($open)
 
;~ ConsoleWrite($data & @CRLF)
 
$array = StringRegExp($data, "U ([\h\w\d_]*):AOL;Instant;Messenger", 3)
 
debug($array)
 
Func Debug($variable1 = "", $variable2 = "", $variable3 = "")
 
If IsArray($variable1) Then
_ArrayDisplay($variable1)
Else
If $variable2 <> "" Then
$variable1 &= @CRLF & $variable2
EndIf
 
If $variable3 <> "" Then
$variable1 &= @CRLF & $variable3
EndIf
 
ClipPut($variable1)
MsgBox($msg_normal, "Debug", $variable1)
EndIf
 
EndFunc   ;==>Debug

any help is appreciated!

Edited by gcue

Share this post


Link to post
Share on other sites
FireFox

Hi,

Try this:

$s = "U baleywash12::AOL;Instant;Messenger baleywash1,wash,wash"

$a = StringRegExp($s, "Instant;Messenger (\w+),(\w+)?", 3)
;~ $a = StringRegExp($s, "Instant;Messenger (.*?),(.*?)?", 3)

_ArrayDisplay($a)
Note: w only applys on alpha numeric chars (+ space and underscore), otherwise use (.*?)

Edit: See my edit.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
gcue

works only on the first example but not the last 2


U baleywash12::AOL;Instant;Messenger baleywash1,wash,wash

(baleywash1 = screen name, wash = nick name)

 

U tikellyjp2::AOL;Instant;Messenger tikellyjp,tim;kelly,tim;kelly

(tikellyjp = screen name, tim kelly = nick name)

 

U jegdk2::AOL;Instant;Messenger jegdk,

(jegdk = screen name and nick name)

 

thanks for your help!

Share this post


Link to post
Share on other sites
FireFox

ah.

#include <Array.au3>

;~ $s = "U baleywash12::AOL;Instant;Messenger baleywash1,wash,wash"
;~ $s = "U tikellyjp2::AOL;Instant;Messenger tikellyjp,tim;kelly,tim;kelly"
$s = "U jegdk2::AOL;Instant;Messenger jegdk,"

$a = StringRegExp($s, "Instant;Messenger (.*?),(?:(.*?)[,|$])?", 3)

_ArrayDisplay($a)
Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
gcue

works great =)

thank you very much!

Share this post


Link to post
Share on other sites
FireFox

hehe, I'm only a beginner (since a long time...) with reg exps.

Maybe someone more advanced will popup with a non-lazy solution :)

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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
Sign in to follow this  

×