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 

find replace » right angle quotes

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
acowbear



Joined: 14 May 2006
Posts: 45

PostPosted: Sun Nov 09, 2008 11:04 pm    Post subject: find replace » right angle quotes Reply with quote

right angle quotes just look like tabs in a text file, but if you have your text editor set to show special characters its glyph is the » symbol. I need to do a find replace in a string I loaded from a .txt that has several of these characters and I need to do a find replace on them.

I've tried this as an expreiment to try and get it to work.
in the variable "text" the big spaces are actually right angle quotes.
It attempts to replace the right angle quotes with xxx.
Code:

special=
(
»
)
text=
(
   test   days   11/10/08 8:00 AM   11/20/08 5:00 PM
)
StringReplace,text,text,%special%,xxx,UseErrorLevel
msgbox, %text%


so...any ideas?
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Nov 10, 2008 4:09 am    Post subject: Re: find replace » right angle quotes Reply with quote

acowbear wrote:
right angle quotes just look like tabs in a text file, but if you have your text editor set to show special characters its glyph is the » symbol. I need to do a find replace in a string I loaded from a .txt that has several of these characters and I need to do a find replace on them.

I've tried this as an expreiment to try and get it to work.
in the variable "text" the big spaces are actually right angle quotes.
It attempts to replace the right angle quotes with xxx.
so...any ideas?


That description is very confusing, I don't know whether you are trying to replace "»" characers or literal tabs. So I show you how to do both here (tested).
Code:
#SingleInstance, force
special1 = »
text1 =  »test»days»11/10/08 8:00 AM»11/20/08 5:00 PM

special2 := A_Tab
text2 := A_Tab "test" A_Tab "days" A_Tab "11/10/08 8:00 AM" A_Tab "11/20/08 5:00 PM"

msgbox,,text1 and text2 before replace,%text1%`n%text2%
StringReplace,text1,text1,%special1%,xxx,UseErrorLevel
StringReplace,text2,text2,%special2%,xxx,UseErrorLevel
msgbox,, text1 and text2 after replace, %text1%`n%text2%
Back to top
acowbear



Joined: 14 May 2006
Posts: 45

PostPosted: Mon Nov 10, 2008 1:18 pm    Post subject: Reply with quote

Sorry.
The » is not an actual character, it is a visual representation of something invisible. What I am deeling with is an "INVISIBLE" special character within my text files. » is the glyph that represents it when you have a program able to visually represent invisible characters. For exampe, linefeeds are represented as ¶ and spaces are represented as
the · symbol.

So what I need to do is a find-replace on something invisible. Linefeeds are invisible, but in hotkey are represented as `n. Tabs are invisible, but represented as %A_Tab% in autohotkey. Spaces are invisible but in hotkey represented as %A_Space%. I need to do a find replace on the invisible character that is represented as » within my text editor (CONText) when I turn on "Show Special Characters" mode.

How do I find replace on this invisible character?
Back to top
View user's profile Send private message
same guest
Guest





PostPosted: Mon Nov 10, 2008 2:14 pm    Post subject: Reply with quote

acowbear wrote:

How do I find replace on this invisible character?

Well, you cannot search for an unknown character. You will need to examine the file using an editor that allows you to view the file in a hex format (I don't know about CONText, but many other editors allow this). Once you know the hex value of the character you want to replace, you can use the value like this:
Assuming the you identify the character as 0x1E (ascii record separator)
Code:
special := Chr(0x1E)
StringReplace,text,text,%special%,xxx,UseErrorLevel
Back to top
acowbear



Joined: 14 May 2006
Posts: 45

PostPosted: Mon Nov 10, 2008 2:17 pm    Post subject: SOLVED!!! Reply with quote

Ok, I figured it out.


Code:

special=
(
x   x
)
StringReplace,special,special,x,,UseErrorLevel
text=
(
   test   days   11/10/08 8:00 AM   11/20/08 5:00 PM
)
StringReplace,text,text,%special%,xxx,UseErrorLevel
msgbox, %text%


-------WITH SPECIAL CHARACTERS BEING SHOWN VISUALLY----
special=
(
x       »   x
)
StringReplace,special,special,x,,UseErrorLevel
text=
(
 »   test  » days  »   11/10/08 8:00 AM  »  11/20/08 5:00 PM
)
StringReplace,text,text,%special%,xxx,UseErrorLevel
msgbox, %text%



Whats going on is that, in order to get the invisible character that is represented by » into a variable, I needed to paste it into the variable special between 2 normal, visible characters, and then use a stringreplace to delete the normal characters. Once the variable "special" contains only my invisible special character, I am able to use it to do the find replace I needed. Yeay!
Back to top
View user's profile Send private message
mange



Joined: 14 Feb 2009
Posts: 2

PostPosted: Sat Feb 14, 2009 4:25 am    Post subject: Reply with quote

same guest wrote:

Assuming the you identify the character as 0x1E (ascii record separator)
Code:
special := Chr(0x1E)
StringReplace,text,text,%special%,xxx,UseErrorLevel


OMG this worked!!!
Hours of searching for errors and then I found out that it was a special linefeed, then another hour of trying to replace it with all kind of different regExReplace commands, but nothing worked.

thanks so much for this Very Happy Very Happy Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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