gcue Posted August 19, 2013 Posted August 19, 2013 (edited) 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 August 19, 2013 by gcue
FireFox Posted August 19, 2013 Posted August 19, 2013 (edited) 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 August 19, 2013 by FireFox
gcue Posted August 19, 2013 Author Posted August 19, 2013 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!
FireFox Posted August 19, 2013 Posted August 19, 2013 (edited) 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 August 19, 2013 by FireFox
FireFox Posted August 19, 2013 Posted August 19, 2013 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now