AutoHotkey Community

It is currently May 26th, 2012, 11:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: November 10th, 2008, 12:04 am 
Offline

Joined: May 14th, 2006, 8:31 pm
Posts: 45
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?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 10th, 2008, 5:09 am 
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%


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 10th, 2008, 2:18 pm 
Offline

Joined: May 14th, 2006, 8:31 pm
Posts: 45
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 10th, 2008, 3:14 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: SOLVED!!!
PostPosted: November 10th, 2008, 3:17 pm 
Offline

Joined: May 14th, 2006, 8:31 pm
Posts: 45
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2009, 5:25 am 
Offline

Joined: February 14th, 2009, 5:16 am
Posts: 2
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 :D :D :D


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, BrandonHotkey, Exabot [Bot], Yahoo [Bot] and 54 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