Jump to content

parsing out data


gcue
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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
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...