AutoHotkey Community

It is currently May 27th, 2012, 10:51 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 789 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 53  Next
Author Message
 Post subject:
PostPosted: October 23rd, 2006, 11:27 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Should include in the test:
Code:
Loop C:\*.BMP,0,1
{
   imageFiles := imageFiles . A_LoopFileLongPath . "`n"
}
Loop C:\*.JPG,0,1
{
   imageFiles := imageFiles . A_LoopFileLongPath . "`n"
}
Loop C:\*.GIF,0,1
{
   imageFiles := imageFiles . A_LoopFileLongPath . "`n"
}
Probably faster, as the system returns only relevant files, instead of getting all files and filtering them after.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 6:44 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
My test was RegExMatch Vs SplitPath .. :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 9:50 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Yeah, I was thinking about PhiLhos test.

Quote:
Probably faster, as the system returns only relevant files, instead of getting all files and filtering them after.

Probably faster ? :D

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 11:37 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Goyyah wrote:
My test was RegExMatch Vs SplitPath .. :)

This test is based upon if..in and regex:
Code:
SetBatchLines, -1
Process, Priority, , R
dir = %A_MyDocuments%\*.*
i = 100

t1 := A_TickCount
Loop, %i% {
   Loop, %dir%, , 1
      If A_LoopFileExt in bmp,jpg,gif
         list = %list%%A_LoopFileFullPath%`n
   list := ""
}

t2 := A_TickCount
Loop, %i% {
   Loop, %dir%, , 1
      If RegExMatch(A_LoopFileExt, "^bmp|jpg|gif$", "i")
         list = %list%%A_LoopFileFullPath%`n
   list := ""
}

t3 := A_TickCount
MsgBox, % "if..in:`t" . t2 - t1 . "`nregex:`t" . t3 - t2

Seems like regex is faster!!1

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 11:49 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
@Titan: Unbelievable! :shock: I never knew A_LoopFileExt existed! :(

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on October 24th, 2006, 11:49 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 11:49 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Look like we got superb tool to play with.

I can not get it how RegExp can be faster than any concrete string function, but this just proves that this re implementation is good and optmised.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 11:52 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
majkinetor wrote:
this just proves that this re implementation is good and optmised.
What is it btw, pcre 6.7?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 12:07 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
How to find the number of a particular character/string/whole word present in a string?

My basic need is find the number of delimiters in a string and would like to have a one line solution like:

Code:
;I want to ascertain the number of semi colons and add 1 to
; find the no.of fields
FieldCount := RegEx??("Apples;Bananas;Cherries", ...) + 1


Refer this post: http://www.autohotkey.com/forum/viewtop ... 4194#84194

I would also like to know how the matches can be counted for a substring or a whole word

Please refer this topic : Count instances of a word appears in a file

:?:

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 12:37 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Goyyah wrote:
How to find the number of a particular character/string/whole word present in a string?
Easy: MsgBox, % StrLen(RegExReplace("one; two; three; four", "[^;]", ""))

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 12:48 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Titan wrote:
majkinetor wrote:
this just proves that this re implementation is good and optmised.
What is it btw, pcre 6.7?
I believe so.
Indeed, the code is highly optimized. For example, author doesn't hesitate to put similar code several time to avoid adding a test in the loop... And it uses goto when it saves some CPU cycles! :-)
I didn't saw that in PCRE code (but might have skipped it), but some implementations can detect that the RE is plain text. In this case, they just use an optimized Boyer-Moore string search...

Goyyah, I made a variant of the SplitPath functions, published in the other topic. They might not please you, as they don't use simple assignment, but I felt I had to test this possibility.
It seems latest beta (options in regex) broke the multiline (extended) REs, I will report that.

To answer your latest request is easy, Chris provided a OutputVarCount to the RegExReplace function:
Code:
str = Apples;Bananas;Cherries
RegExReplace(str, ";", "", count)
FieldCount := count + 1
MsgBox % FieldCount

str = Recommended for new scripts due to its superior speed and reliability.
RegExReplace(str, "\w+", "", count)
MsgBox % count

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 1:07 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
PhiLho wrote:
Goyyah, I made a variant of the SplitPath functions, published in the other topic.


Thanks for the elaborate posting!
BTW, R: How to emulate StringSplit? should be R: How to emulate SplitPath?, I guess!
I am posting here because I do not want to mess that topic.
I would like to see that topic become sticky someday! :)

Quote:
To answer your latest request is easy, Chris provided a OutputVarCount to the RegExReplace function


I get blank values! :roll:

:)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 1:12 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Titan wrote:
MsgBox, % StrLen(RegExReplace("one; two; three; four", "[^;]", ""))


Works fine! Thanks!
How do I count "e;" from that string?

:)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 2:51 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Goyyah wrote:
How do I count "e;" from that string?
That's quite tricky - it's like doing a StringReplace (All). One way is to: StrLen(RegExReplace("one; two; three; four" . " ", ".*?(?:(?<=e;)(.)|$)", "$1")) but it requires at least one character at the end of the string to catch ending delimiters.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 2:57 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Titan wrote:
it requires at least one character at the end of the string to catch ending delimiters.


Oh! I did not guess that would be tough. Many thanks! :D

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2006, 2:59 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Goyyah wrote:
I get blank values! :roll:
:?: I tested the above with the latest beta, did you got it? I can't remember if this count of replaces was in the previous version.

Goyyah wrote:
How do I count "e;" from that string?
Sorry, I don't understand. Do you mean RegExReplace(str, "e;", "", count)?

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 789 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 53  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, Google [Bot], Google Feedfetcher, HotkeyStick, krajan, Yahoo [Bot] and 30 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group