AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Put here requests of problems with regular expressions
Goto page Previous  1, 2, 3, 4, 5 ... 17, 18, 19  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Titan



Joined: 11 Aug 2004
Posts: 5376
Location: /b/

PostPosted: Tue Oct 24, 2006 2:05 pm    Post subject: Reply with quote

PhiLho wrote:
Sorry, I don't understand. Do you mean RegExReplace(str, "e;", "", count)?
See my example a couple posts up.

Goyyah wrote:
Oh! I did not guess that would be tough.
I'm no regex expert. I'm sure it's possible to avoid the extra chars with a conditional and an atomic grouped lookaround... but I'll leave that to PhiLho, majkinetor, JSLover and the other regex nerds Razz
_________________

Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Tue Oct 24, 2006 2:07 pm    Post subject: Reply with quote

PhiLho wrote:
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.


Where do I get it? Rolling Eyes

PhiLho wrote:
Sorry, I don't understand. Do you mean RegExReplace(str, "e;", "", count)?


I want to count e; in "One;Two;Three;Four;Five",
the result will be 2!

Smile
_________________
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Tue Oct 24, 2006 2:09 pm    Post subject: Reply with quote

Titan wrote:
I'm sure it's possible to avoid the extra chars with a conditional and an atomic grouped lookaround...


Please do not bash me! Very Happy
_________________
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Tue Oct 24, 2006 2:12 pm    Post subject: Reply with quote

This will return count in my version:

v := RegExMatch(var, "e")
_________________
Back to top
View user's profile Send private message MSN Messenger
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Tue Oct 24, 2006 2:15 pm    Post subject: Reply with quote

majkinetor wrote:
This will return count in my version:


What version? Rolling Eyes

Let me guess.. you guys were privately notified with a link for download?

Question

Edit: Stupid of me! I do not know how I missed it!
_________________


Last edited by SKAN on Tue Oct 24, 2006 2:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Tue Oct 24, 2006 2:17 pm    Post subject: Reply with quote

You guessed wrong... I downloaded it from forum

Well...it seems that above doesn't work well...

Code:
var := "mone;y toke;ne"
v := RegExMatch(var, "e;")
msgbox %v%


Returns 4

RegExMatch (var, "o") returns 2
RegExMatch(var, "e;y") returns 4 ...
RegExMatch(var, "`;y") returns 5 ?


I don't get this really as

Quote:

var := "mone;y toke;ne"
v := RegExReplace(var, "e;", "", count)
msgbox %count%


Returns 2


For now, goyah, you can use RegExReplace(var, "e;", "e;", count)
_________________
Back to top
View user's profile Send private message MSN Messenger
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Tue Oct 24, 2006 2:51 pm    Post subject: Reply with quote

Dear PhiLho, Smile

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


Thats cool too.. but I meant searching a whole word.. For example:

"The Theft Broke-in Through The Window"

I want to search for "the" ( case insensitive ) and result should be 2 .. not 3

Smile
_________________
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Oct 24, 2006 3:07 pm    Post subject: Reply with quote

Goyyah wrote:
Where do I get it? Rolling Eyes
Same address as the previous one: Regular Expressions (RegEx) for AutoHotkey

Goyyah wrote:
I want to count e; in "One;Two;Three;Four;Five",
the result will be 2!
Yes, that's what I gave (again, lastest version!). I was lost because Titan provided a complex expression...

majkinetor wrote:
This will return count in my version:
v := RegExMatch(var, "e")
[...]
Well...it seems that above doesn't work well...
Uh, no, in both versions, it returns the found position...

Goyyah wrote:
Thats cool too.. but I meant searching a whole word.. For example:

"The Theft Broke-in Through The Window"

I want to search for "the" ( case insensitive ) and result should be 2 .. not 3
Ah, counting a given word. No problem:
Code:
str = The Theft Broke-in Through The Window
RegExReplace(str, "i)\bthe\b", "", count)
msgbox %count%
\b is "word bound", working also on string ends.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Tue Oct 24, 2006 3:24 pm    Post subject: Reply with quote

PhiLho wrote:
counting a given word. No problem:
Code:
str = The Theft Broke-in Through The Window
RegExReplace(str, "i)\bthe\b", "", count)
msgbox %count%
\b is "word bound", working also on string ends.


Thanks! Very Happy RegEx is very interesting!
_________________
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5376
Location: /b/

PostPosted: Tue Oct 24, 2006 3:29 pm    Post subject: Reply with quote

PhiLho wrote:
RegExReplace(str, "e;", "", count)?
PhiLho wrote:
I was lost because Titan provided a complex expression...

Oh I never knew RegExReplace had that feature. I also didn't know how to convert ++/e;/.exec('one; two; three; four').length; javascript to ahk, hence my long-winded approach. Goyyah (and Laszlo) prefer one-line solutions so: Asc(RegExReplace("one; two; three; four", "e;", "", c)) * 0 + c
_________________

Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Tue Oct 24, 2006 3:36 pm    Post subject: Reply with quote

Titan wrote:
Goyyah (and Laszlo) prefer one-line solutions


Definitely yes!

Code:
str = The Theft Broke-in Through The Window of The House
MsgBox, % Asc(RegExReplace(str,"i)\bthe\b", "", count)) * 0 + count


Many thanks for coming up with that technique! Readable or not, if it is going to be inside my function, I prefer one-liners.

Smile
_________________
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3644
Location: Belgrade

PostPosted: Tue Oct 24, 2006 4:10 pm    Post subject: Reply with quote

Quote:
Uh, no, in both versions, it returns the found position...

well, there is no documentation yet... Smile


Quote:
Thanks! RegEx is very interesting!

Yeah, goyyah, its perfect for your camp. Smile
_________________
Back to top
View user's profile Send private message MSN Messenger
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Oct 24, 2006 4:30 pm    Post subject: Reply with quote

majkinetor wrote:
well, there is no documentation yet... Smile
Only some lines in the first announce of the beta...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Tue Oct 24, 2006 4:41 pm    Post subject: Reply with quote

Can a string be converted into Upper/Lower/Sentence case with RegExReplace?

Forgive me if it is a stupid request!
_________________
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5376
Location: /b/

PostPosted: Tue Oct 24, 2006 4:58 pm    Post subject: Reply with quote

Goyyah wrote:
Can a string be converted into Upper/Lower/Sentence case with RegExReplace?
I don't think it's possible, what's wrong with StringLower/StringUpper anyway?
_________________

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2, 3, 4, 5 ... 17, 18, 19  Next
Page 4 of 19

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group