techshots Posted May 23, 2006 Share Posted May 23, 2006 Hi, I have a file called "sourcetoc2.txt' which contains this: :</B>Before you begin:</B> My script below searches for this part of the string above :</B> but is unable to find the string in this line: $CHECK_SRC_1 = StringInStr($aRecords[$x], ":</B>") I think the forward slash and maybe the colon are both special characters? First is there a list of special characters I can use for future reference? Second, How do I solve this? I've tried the following: $..............chr(47) & "B") and many variations thereof...with no luck Third, is there an escape character for the special characters? Thanks a bunch ahead of time. full code below: #include <file.au3> Dim $aRecords If Not _FileReadToArray("F:\hien\saveurl\sourcetoc.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] ;msgbox(0,'', $aRecords[$x]) $CHECK_SRC_1 = StringInStr($aRecords[$x], ":</B>") ;msgbox(0,"",$CHECK_SRC_1) ; grab the desired header lines if $CHECK_SRC_1 = 1 Then ; get rid of all the unwanted strings $READ_SRC_1 = $aRecords[$x] ;MsgBox(0,"",$READ_SRC_1) $REPL1 = StringReplace($READ_SRC_1, "<B>","") $REPL2 = StringReplace($REPL1, ":</B>","") $REPL3 = StringReplace($REPL2, "<BR>","") $REPL4 = StringReplace($REPL3, "<U>","") $REPL5 = StringReplace($REPL4, "</U>","") ;strip of all leading and trailing spaces- must do this else create folder won't work $STRIP_CR1 = StringStripWS($REPL5,1) $STRIP_CR2 = StringStripWS($STRIP_CR1,2) ;msgbox(0, "STRIP_CR ", $STRIP_CR2) ; create folder names from header titles extracted above ;sgbox(0, " ", $REPL3) DirCreate('F:\hien\results\' & $STRIP_CR2 ) ;DirCreate($DIR_NAME) EndIf Next Exit Link to comment Share on other sites More sharing options...
techshots Posted May 23, 2006 Author Share Posted May 23, 2006 I figured it out my apologies I changed this if $CHECK_SRC_1 = 1 Then to this if $CHECK_SRC_1 <> 0 Then and works.. sorry! Hi, I have a file called "sourcetoc2.txt' which contains this: :</B>Before you begin:</B> My script below searches for this part of the string above :</B> but is unable to find the string in this line: $CHECK_SRC_1 = StringInStr($aRecords[$x], ":</B>") I think the forward slash and maybe the colon are both special characters? First is there a list of special characters I can use for future reference? Second, How do I solve this? I've tried the following: $..............chr(47) & "B") and many variations thereof...with no luck Third, is there an escape character for the special characters? Thanks a bunch ahead of time. full code below: #include <file.au3> Dim $aRecords If Not _FileReadToArray("F:\hien\saveurl\sourcetoc.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] ;msgbox(0,'', $aRecords[$x]) $CHECK_SRC_1 = StringInStr($aRecords[$x], ":</B>") ;msgbox(0,"",$CHECK_SRC_1) ; grab the desired header lines if $CHECK_SRC_1 = 1 Then ; get rid of all the unwanted strings $READ_SRC_1 = $aRecords[$x] ;MsgBox(0,"",$READ_SRC_1) $REPL1 = StringReplace($READ_SRC_1, "<B>","") $REPL2 = StringReplace($REPL1, ":</B>","") $REPL3 = StringReplace($REPL2, "<BR>","") $REPL4 = StringReplace($REPL3, "<U>","") $REPL5 = StringReplace($REPL4, "</U>","") ;strip of all leading and trailing spaces- must do this else create folder won't work $STRIP_CR1 = StringStripWS($REPL5,1) $STRIP_CR2 = StringStripWS($STRIP_CR1,2) ;msgbox(0, "STRIP_CR ", $STRIP_CR2) ; create folder names from header titles extracted above ;sgbox(0, " ", $REPL3) DirCreate('F:\hien\results\' & $STRIP_CR2 ) ;DirCreate($DIR_NAME) EndIf Next Exit Link to comment Share on other sites More sharing options...
GEOSoft Posted May 24, 2006 Share Posted May 24, 2006 (edited) I figured it out my apologies I changed this if $CHECK_SRC_1 = 1 Then to this if $CHECK_SRC_1 <> 0 Then and works.. sorry!I would also take a look at $STRIP_CR1 = StringStripWS($REPL5,1) $STRIP_CR2 = StringStripWS($STRIP_CR1,2) Try $REPL5 = StringStripWS($REPL5,3) Better yet DirCreate('F:\hien\results\' & StringStripWS($REPL5,3)) Edited May 24, 2006 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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