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. General Programming
  3. C#
  4. Regex Question: Match if absent

Regex Question: Match if absent

Scheduled Pinned Locked Moved C#
regexquestioncomhelp
5 Posts 3 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.
  • M Offline
    M Offline
    matthias s 0
    wrote on last edited by
    #1

    hi there, I've got a regular expression which should match an url: (http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?) this is fine. but now I want to make sure, that the url is not enclosed by ". that means, this http://bla.com should match, some text http://bla.com more text should match as well but this "http://bla.com" shouldn't. i've tried this, which doesn't work: [^"](http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?)[^"] can anyone help? thanks in advance!

    /matthias

    I love deadlines. I like the whooshing sound they make as they fly by.
    [Douglas Adams]

    C 1 Reply Last reply
    0
    • M matthias s 0

      hi there, I've got a regular expression which should match an url: (http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?) this is fine. but now I want to make sure, that the url is not enclosed by ". that means, this http://bla.com should match, some text http://bla.com more text should match as well but this "http://bla.com" shouldn't. i've tried this, which doesn't work: [^"](http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?)[^"] can anyone help? thanks in advance!

      /matthias

      I love deadlines. I like the whooshing sound they make as they fly by.
      [Douglas Adams]

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      ([^\x22]http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?[^\x22])

      :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      M V 2 Replies Last reply
      0
      • C CPallini

        ([^\x22]http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?[^\x22])

        :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        M Offline
        M Offline
        matthias s 0
        wrote on last edited by
        #3

        thanks, this is it. well almost. the problem is, if I have a string which contains only an url, that is http://bla.com or a string which looks like peter, look here:http://bla.com! have you seen? they both don't work. in the first case, no match is returned, in the second one, :http://bla.com! is returned instead of http://bla.com. If I start the regex with ([^\x22]**?**http\://... then again it will match the " as well. I'm getting grey hair on that one and would greatly appreciate further assistance.

        /matthias

        I love deadlines. I like the whooshing sound they make as they fly by.
        [Douglas Adams]

        1 Reply Last reply
        0
        • C CPallini

          ([^\x22]http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?[^\x22])

          :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

          V Offline
          V Offline
          V 0
          wrote on last edited by
          #4

          hey, I've tried to use some regular expressions as well today and had a real hard time finding out the correct expression. Do you have a good link or something that explains this? MSDN really s*cks on this. thanks

          V. I found a living worth working for, but haven't found work worth living for.

          C 1 Reply Last reply
          0
          • V V 0

            hey, I've tried to use some regular expressions as well today and had a real hard time finding out the correct expression. Do you have a good link or something that explains this? MSDN really s*cks on this. thanks

            V. I found a living worth working for, but haven't found work worth living for.

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #5

            V. wrote:

            MSDN really s*cks on this

            I agree. But, unfortunately, at the moment, MSDN is my only reference on regular expressions. Ask here at CP, I think there are a lot of people far more experts than me about regular expressions. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

            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