Jump to content

How to remove Case sensetive from this ?

Recommended Posts

$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 post
Share on other sites

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 by ac1dm4n

[u]My dream is to have a dream...[/u]

Link to post
Share on other sites
  • Moderators


Welcome to the Autoit forum. :D

RegExes are not the easiest subject to choose as your first post! :D

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. :)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to post
Share on other sites

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)
  $Found = 0
  GUICtrlSetData ($SearchButton,"Stop !")
  $SearchInput = GUICtrlRead($Input)
  _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 !")
    $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)
  GUICtrlSetData ($SearchButton,"Go !")
  _GUICtrlStatusBar_SetText ($StatusBar,"Found " & $Found & " instances")

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 post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...