Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. match word regular expression

match word regular expression

Scheduled Pinned Locked Moved ASP.NET
regexperformancehelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    suzyb
    wrote on last edited by
    #1

    I'm having a bit of trouble with a regular expression. I need to match a url when it is something like services/service1.aspx but not when it is services/default.aspx. I thought this would work \bservices\b\/[^default]\.aspx but it doesn't seem to and neither does this \bservices\b\/[^d][^e][^f][^a][^u][^]][^l][^t]\.aspx. Can anyone help me with this. Thanks SuzyB If I had a better memory I would remember more.

    A 1 Reply Last reply
    0
    • S suzyb

      I'm having a bit of trouble with a regular expression. I need to match a url when it is something like services/service1.aspx but not when it is services/default.aspx. I thought this would work \bservices\b\/[^default]\.aspx but it doesn't seem to and neither does this \bservices\b\/[^d][^e][^f][^a][^u][^]][^l][^t]\.aspx. Can anyone help me with this. Thanks SuzyB If I had a better memory I would remember more.

      A Offline
      A Offline
      Alsvha
      wrote on last edited by
      #2

      Perhaps "services/[^default].+\.aspx" is usefull enough for you. this matches "services/something.aspx" but neither "services/default.aspx" nor "services/something.htm" --------------------------- 127.0.0.1 - Sweet 127.0.0.1

      S 1 Reply Last reply
      0
      • A Alsvha

        Perhaps "services/[^default].+\.aspx" is usefull enough for you. this matches "services/something.aspx" but neither "services/default.aspx" nor "services/something.htm" --------------------------- 127.0.0.1 - Sweet 127.0.0.1

        S Offline
        S Offline
        suzyb
        wrote on last edited by
        #3

        Thanks, that worked, but for only about half the urls I needed to check. I played about with it a bit and found that this seems to work services/.+[^default].+\.aspx. It doesn't match all words but I think it'll do for my purposes. SuzyB If I had a better memory I would remember more.

        A 1 Reply Last reply
        0
        • S suzyb

          Thanks, that worked, but for only about half the urls I needed to check. I played about with it a bit and found that this seems to work services/.+[^default].+\.aspx. It doesn't match all words but I think it'll do for my purposes. SuzyB If I had a better memory I would remember more.

          A Offline
          A Offline
          Alsvha
          wrote on last edited by
          #4

          Otherwise - try and post some more examples, and perhaps somebody can supply a more effective pattern :) But, anyways - now you have something to step up on. --------------------------- 127.0.0.1 - Sweet 127.0.0.1

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups