This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to make expression filter case INdependent

dear readers,

is there a way to match all various cases of a word (viagra for example) using one expression, or not? (then I would have to enter viagra, Viagra, vIagra, viAgra, etc, etc, etc.... (you get the idea)

Case independent matching seems MUCH more logical to me than case dependent... It's the actual word that triggers the rule, not the capitalisation it happens to be in... right..?


This thread was automatically locked due to age.
  • QuItE RiGhT.

    Unfortunately, many regular expression engines do not afford a case insensitive match. A few do, through use of a command-line switch.

    This came about because the regular expression tools were first put to use on Unix platforms by developers (searching source files and whatnot), where case matters.

    Maybe Astaro will share with us a trick way to make it happen, or a guestimate of when we might see a fix...
  • Does (?i-sm) work on Astaro?

    It would be huge if (?ifthen|else) is supported (on another page at that site). "Greedy" matches are a big RegEx problem...
  • ok, thanks very much, that works.

    For people having the same problem, here's the solution:

    (?i)viagra

    this example matches any case of viagra (Viagra, viAgra, whatever)

    Still think that this should really be the standard behaviour...

    Thanks for helping out!
  • Then sm probably works too.

    Now we can search for dangerous HTML elements...
  • hmm... I'm not that clever... could you post an example..?
  • Since I just found this out, I don't have a formal example ready to roll;
    but, for example, if you wanted to disable script "behaviors" in HTML that use attributes beginning with on... (scriptlet">). Or for that matter, what if I want to knock out a scipt block?? (...) Whenever this things spanned multiple lines, the damn default behavior of the parser would not look beyong the line the match started on. So a simple RegEx would not catch the following:

         <>...
                    onLoad="scriptlet">

    or...

         
    .
    .
    .
         

    Also, if you were using sed or awk to strip script from HTML, and had multiple script blocks in your HTML page (which often happens):

    ...
    .
    .
    .
    some HTML markup you want to let through...
    .
    .
    .
    ...

    a match for something that starts with  and ends with  would find the most outer matching pair (a.k.a., a "greedy" match), and end up gobbling up the HTML markup you wanted to let through (you would end up with a blank page, which I have seen incidentally when people were using AntiVirus products...). With ifs (and some of the other new additions shown at that site), I can regulate the behavior to get the closest pairings and knock them out...

    AND:

    You can do this with MIME encodings too.
    So now you can block dangerous mime application types (well, you always could, if you knew this newer additional switch...)

    P.S. You could write a program using Perl or gcc to do any of this parsing and/or reformatting, but a collection of RegExes is more elegant, portable, and open to inspection...
  • right...! [:)]

    interesting, thanks for taking the time to explain!

    yours,
    mourik jan
  • OOPS. there is still a problem with my 'solution' to filter mail case independant. BECAUSE:
    "(?i)cialis" also matches this string INSIDE other words. Meaning: blocking cialis (a viagra alternative, from what i gather..?) also blocks mails containing the word "specialising", as it contains "cialis".

    So... any idea how to add a space before and after the term..? this doesn't work:

    (?i) viagra 
    (i've simply put a space before and after)

    Suggestions?
  • found it: \b matches a word boundary, so

    (?i)\bcials\b

    does the trick

    also this works:
    (?i)\btest test\b

    macthes only "test test"

    Am i right..? [:)]portant..?)

    Thanks anyway.