AutoHotkey Community

It is currently May 26th, 2012, 9:21 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: July 24th, 2005, 1:21 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2543
Hi :) ,

I was wondering... Could StringReplace be extended to replace only single instances of the SearchText. and/or exclude certain strings ?

For example... in the string "AA,DE,0A,22,14,FF, A2" replace only single instances of A with C with using the All option for a result of "AA, DE, 0C, 22, 14, FF, C2"

or... in the string "AAA,DCE,0AA,212,134,FFF, A02" replace instances of A with C but exclude AA with using the All option for a result of "CCC,DCE,0AA,212,134,FFF, C02"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2005, 12:50 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I think the rarity of the need for this means it should be written as a script function. Such functions could eventually be made a part of the program's standard includes library (which has not yet been implemented).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2005, 2:36 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2543
:(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2005, 11:14 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Don’t cry! It is not that hard to get it done. First replace every AA with something you don’t have in the string, like # (can be really long and weird string), then A->C and finally #->AA. Only 3 lines of code!

Your second example is only a little more complex: AAA->$, AA->#, $->AAA, A->C, #->AA. Five lines, assuming the structure of your text is similar to the one you showed. Of course, in general cases it is not that easy. (OK, you can cry.)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2005, 1:27 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2543
Laszlo wrote:
Don’t cry! It is not that hard to get it done. First replace every AA with something you don’t have in the string, like # (can be really long and weird string), then A->C and finally #->AA. Only 3 lines of code!
That was the problem actually. I was looking for a method that does not involve replacing characters as I will not know which characters have not been used. The manual solution without replacing characters is not too difficult (at least I'm pretty sure it isn't...) but I was trying to avoid adding another function. Chris is very likely correct that not many people would have a use for this but I can see myself using it quite a bit. I'll see if I can come up with a handy, dandy function... :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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