leuce Posted November 21, 2006 Share Posted November 21, 2006 G'day everyone I have pieces of text with HTML-style tags in them, like this: <a0>This is a <a0/><b1>house<b1/>. and I'd like to use a script to remove the tags, so that I end up wit this: This is a house. Of course, I could copy the text, past it into a text editor, and use regex find/replace to remove the tags, then copy the text again, but that is a long way and it is dependent on the user's computer having the correct text editor installed. I was hoping that there is some way in AutoIt itself to do this. Thanks Samuel Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 21, 2006 Moderators Share Posted November 21, 2006 Use File Read or _InetGetSource() and try this:$sString = "<a0>This is a <a0/><b1>house<b1/>." $sString = StringRegExpReplace($sString, '(?s)(?i)\<[^\>]*\>', '') MsgBox(0,'', $sString)The original $sString will be the FileRead() or _InetGetSource(). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Outshynd Posted November 21, 2006 Share Posted November 21, 2006 #include <File.au3> Dim $lines, $file = "test.txt" If Not _FileReadToArray($file, $lines) Then MsgBox(16, "Error 1", "File could not be read to array.") Exit Else If IsArray($lines) And $lines[0] > 0 Then For $i = 1 To $lines[0] $lines[$i] = StringRegExpReplace($lines[$i], '(?s)(?i)\<[^\>]*\>', '') Next FileDelete($file) _FileWriteFromArray($file, $lines, 1) EndIf EndIf Something like that. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 21, 2006 Moderators Share Posted November 21, 2006 #include <File.au3> Dim $lines, $file = "test.txt" If Not _FileReadToArray($file, $lines) Then MsgBox(16, "Error 1", "File could not be read to array.") Exit Else If IsArray($lines) And $lines[0] > 0 Then For $i = 1 To $lines[0] $lines[$i] = StringRegExpReplace($lines[$i], '(?s)(?i)\<[^\>]*\>', '') Next FileDelete($file) _FileWriteFromArray($file, $lines, 1) EndIf EndIfoÝ÷ Ù*&zØb bëajßêº^6ájÝý²z-Â"y¢Óhç~ÅWy§S ëk$®)àEèÆ^¦V{¥Ú"µ©eÂ+aë-²¶§X¤y«¢+ØÀÌØíÍMÑÉ¥¹=ÕÑAÕÐôMÑÉ¥¹IáÁIÁ±¡¥±I ÌäíÑÍйÑáÐÌä줰Ìäì ý̤ ý¤¤ÀäÈì±ÐímxÀäÈìÐít¨ÀäÈìÐìÌäì°ÌäìÌäì¤All you need is 1 line really... and a FileWrite if you are going to write it to a file. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Outshynd Posted November 21, 2006 Share Posted November 21, 2006 I guess you're right. Could just read the entire file into a variable regardless of line breaks. Not really sure what I was thinking. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 21, 2006 Moderators Share Posted November 21, 2006 I guess you're right. Could just read the entire file into a variable regardless of line breaks. Not really sure what I was thinking.If it's any consolation, when I was writing it, I was trying to do it the hard way myself with just StringRegExp() and took me 20 minutes to realize that I was just making it hard on myself. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
leuce Posted November 21, 2006 Author Share Posted November 21, 2006 Thanks, everyone. All your solutions give me the answer "1", but at least now I know what I should tinker with. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted November 21, 2006 Moderators Share Posted November 21, 2006 You could also use the .innerText method on a parent element of those two objects for the same result. Here is an example of what I mean. #include <IE.au3> $oIE = _IE_Example("basic") $oDiv = _IETagNameGetCollection($oIE, "DIV", 1) $sText = $oDiv.innerText ConsoleWrite($sText & @CR) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 21, 2006 Moderators Share Posted November 21, 2006 Thanks, everyone. All your solutions give me the answer "1", but at least now I know what I should tinker with.You need Beta 3.2.1.8 at least for it to work, and the answer with be right. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now