tonycst Posted April 29, 2012 Share Posted April 29, 2012 $SearchFor = StringRegExpReplace($SearchInput, "([\\\.\*\+\(\)\?\^\$\|\{\}\[\]])", "\\$1") $res = StringRegExp($source, "(?im)^.*" & $SearchFor & ".*$", 3) I dont get this part of code and dont know how to remove case sensetive comparing. Can you guys help or explane ? I looked into help file and found that (?i) is supose to be it, but removing it returns no search results at all Link to comment Share on other sites More sharing options...
acidman Posted April 29, 2012 Share Posted April 29, 2012 (edited) try stringinstr it searches for occurrences depeding on the option you set... Then replace the strings with stringreplace, just play around a bit... you'll eventually figure it out. Edited April 29, 2012 by ac1dm4n [u]My dream is to have a dream...[/u] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 29, 2012 Moderators Share Posted April 29, 2012 tonycst,Welcome to the Autoit forum. RegExes are not the easiest subject to choose as your first post! What are you trying to do with the code you have at the moment? It looks as if the StringRegExpReplace line is escaping all action characters within a RegEx so that the pattern for the StringRegExp line can use the result as a pattern. But removing the case sentitivity should be as simple as replacing the (?im) with (?m). However, as I am not sure quite what you are doing I am not sure that is the correct solution. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
acidman Posted April 29, 2012 Share Posted April 29, 2012 (edited) yea expressions I still have trouble with that sometimes tooooo... Edited April 29, 2012 by ac1dm4n [u]My dream is to have a dream...[/u] Link to comment Share on other sites More sharing options...
tonycst Posted April 29, 2012 Author Share Posted April 29, 2012 Well what i am trying to do is search text document containing large text data for a string. This example i pulled out of this forum a while ago was great but it was set to be case sensetive. And because i never worked with these functions before, i didnt know how to make it not to be case sensetive. Maybe the case sensetivity doesnt even come from here, but i dont see any other place in the script where string matching takes place. Text file is large with over 44.500 lines of text, so having "stringinstring" and a ton of if statements per line would slow down search from miliseconds to hours. Here is a piece of a loop in which searching and matching is done. Sorry i should have posted this befor asking. If $msg = $SearchButton Then $source = "textfile.txt" If GUICtrlRead ($TextBook) = "No TextBook Found" Then $AskToGoToDownloadPage = MsgBox(32,"Bible Error"," No TextBook Found." & @CRLF & "Please download TextBook file first by clicking link on the right.",'',$MainGUI) EndIf $Found = 0 GUICtrlSetData ($SearchButton,"Stop !") $SearchInput = GUICtrlRead($Input) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView)) _GUICtrlStatusBar_SetText ($StatusBar,"Searching") $SearchFor = StringRegExpReplace($SearchInput, "([.*+()?^$|{}[]])", "$1") $res = StringRegExp($source, "(?im).*" & $SearchFor & ".*$", 3) If Not @error Then For $line In $res $Loopmsg = GUIGetMsg() If $Loopmsg = $SearchButton Then GUICtrlSetData ($SearchButton,"Go !") ExitLoop EndIf $NewLine = StringTrimLeft ($line,StringInStr($line,"*")) ;returns text without junk such as: T=1,C=10* Actual book text line continues here GUICtrlCreateListViewItem($NewLine, $ListView) Assign ("Found",$Found+1) Next ResizeCollumns() EndIf GUICtrlSetData ($SearchButton,"Go !") _GUICtrlStatusBar_SetText ($StatusBar,"Found " & $Found & " instances") EndIf Am not sure (in this case) how does "For $line in $res" work, maybe this is where i need to study ? In anycase, i tried removing the "i" from "?im" but it didnt help. I am trying to find text such as "it was a Tomato" by searching for "it was a tomato" but i get no search results unless i give it a capitol T So am not sure what defins the search pattern in these functions since they dont make sence at all. Like i said, i found them here and used them without knowing exactly how they work, as long as they get the job i didnt care much untill now. 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