Jump to content
Sign in to follow this  
Leonick

Simple Reg Exp..

Recommended Posts

Leonick

Hi guys....

Struggling around for 3 days to learn regexp now....

got already some results, which i could implemented succesfully.

Reading the help over and over,....doesnt help much,...so mostly I found everything out through examples.

Trying to get the time in a text:

$data="WordA 09:17:58 blabla"
$time = StringRegExp($data,'(?:WordA)(?:.*?)(\d+)', 1)
ConsoleWrite($time[0]&@LF)oÝ÷ Ù¬º[jºtö«¨´­§¨¶Ø^Â%zئy©Ývíëb¶l«zË¥¶ÈhºW[z«¨·Ouï*ºl¢g­)àÂ+aÂÝn§uªònëmè^hzÉí±¬°êÞ¶n¶+bâºw^®ËZÛaÈ­Â¥v¥¦g¯z¼¦¹ÈlyÊ'v«²Ø¨'ò¢æ«zËbY赺+yÙhëçg£h±ê^­«^¶¬x%zئzÉbëajÛbí

but when the time only consists of two numbers like: "09:45" its not working!!

loooooool

HEADACHE......

If i would understand this.....I could make a big step in unterstanding regexp

Thank you for anyone who is willing to expalin.

Leonick

Share this post


Link to post
Share on other sites
PsaltyDS

RegExp: Geeky fun for the whole family!

#include <Array.au3>

Global $avData[2] = ["WordA 09:17:58 blabla", "WordA 09:17 blabla"]
For $n = 0 to UBound($avData) - 1
$time = StringRegExp($avData[$n],'(?:WordA)(?:\D*)(\d{2}:\d{2}(:\d{2})?)', 3)
_ArrayDisplay($time, "$time")
Next

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
ResNullius

Or with StringRegExpReplace

$data="WordA 09:17:58 blabla"
$time = StringRegExpReplace($data, "(.*?)((\d{2}:){1,2}\d{2})(.*)", "\2")
ConsoleWrite($time & @CRLF)

Share this post


Link to post
Share on other sites
Leonick

Geeky fun for the whole family...looool

I think my family will stare to me like a sheep if i wanna explain them. :)

Woooow....i think that will help me out.

Of course i dont wanna simple use your stuff, but mostly important I wanna understand it.

Going to figure it out in a few minutes...just wanted to say "Big Thank You"

If i dont get it,....then i am going to ask back if i may :-)

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  

×