SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    regular expression help

    Hi,

    I need to check a url and need to pass a regular expression to a third party tool. How can i make it where it is not case sensitive?

    ^/summaryreports/(.*)/(.*)?/?$

    In the above i need "summaryreports" to be returned true even if user types in "SummaryReports" or "SUMMARYREPROTS".

    I am passing the above reg-expression to a third party tool so i can't specify the regulary expression to do case in-sensitive search.

    Thanks
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  2. #2
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Below works without a problem but is ugly, is there a better way of doing this?

    [s|S][u|U][m|M][m|M][a|A][r|R][y|Y][r|R][e|E][p|P][o|O][r|R][t|T][s|S]

    Thanks
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,153
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    ugly regex

    If you can't specify case sensitivity then I guess you'll need to use an ugly regex. eg
    [S|s][U|u][M|m][M|m] etc.
    But considering you're using the problem prone "everything" atom, I guess it won't matter much.

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if(/summaryreports/i.exec("SummaryREPORTS")) // do something
    else // do nothing
    is the same couse you just check if this word or format exists than you forward
    the original string...
    cheers

  5. #5
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can ignore the case by using the case-insensitive i flag.

    See http://developer.mozilla.org/en/docs...ultiline_Input

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,153
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    3rd party tool

    If you can't use the "i"
    Quote Originally Posted by tahirjadoon
    I am passing the above reg-expression to a third party tool so i can't specify the regulary expression to do case in-sensitive search.
    and you want to "clean-up" the regex (get rid of the [S|s]'s and (.*)'s), post some detail about the limitations of the 3rd party code you're passing the regex to.

  7. #7
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for the late reply, i am using iis-mod rewrite.

    http://www.micronovae.com/ModRewrite...writeRule.html

    Scroll down on the above link page and you'll see the commands supported by iis-mod rewrite. I have already requested a way to specify through the control center to make search not case sensitive. I guess, i'll get that support in their next release.

    Thanks
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,153
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    no case

    Apache syntax is a bit different than Perl syntax. But the app does support the "no case" option - [NC] - for RewriteRule
    Perform case insensitive text matching. The matching on the input URL will be performed ignoring the case of the URL text.
    and for RewriteCond
    Perform case insensitive text matching. TestString will be tested for matching on Pattern ignoring the case of TestString.
    So if you add the [NC] option it should work OK without the ugly regex.

  9. #9
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, big mistake at my end for not catching this important piece of information in the document.

    TJ
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •