Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:47:16+00:00 2026-06-06T08:47:16+00:00

I am using the XML regex pattern to match my proxy URL. eg: Proxy

  • 0

I am using the XML regex pattern to match my proxy URL.

eg: Proxy : ab-proxy-sample.company.com:8080

My requirement :

  1. Should not begin with http:// OR https:// (Match the whole word)
  2. Should accept any string + a port
  3. Should accept even strings starting with ht

My current XML regex is : [^http://|https://].+:[0-9]+|

But its matching each letter instead of the whole word ?

Any help would be highly appreciated.
Thanks in advance !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:47:18+00:00Added an answer on June 6, 2026 at 8:47 am

    As @arnep points out, you’re attempting to use a negated character class with alternation, which isn’t the way it works. Also, here is some information regarding lookaheads.

    I’m sure someone else will post an answer you can copy and paste, but this is a useful opportunity to learn the basics of regex!

    UPDATE:

    I didn’t realize that you were using an engine that doesn’t support negative lookarounds. Without negative lookarounds, it’s nearly impossible to achieve what you’re trying to do.

    Nearly 😉

    Here is a “brute-force” combinatoric method of doing it:

    (?:[^h]|h(?:[^t]|t(?:[^t]|t(?:[^p]|p(?:[^s:]|s(?:[^:]|:(?:[^\/]|\/(?:[^\/])))|:(?:[^\/]|\/(?:[^\/])))))))\S+:\d+
    
    1. If the XML engine doesn’t support non-captured groups, i.e. (?: ... ) then use regular groups instead:

      ([^h]|h([^t]|t([^t]|t([^p]|p([^s:]|s([^:]|:([^\/]|\/([^\/])))|:([^\/]|\/([^\/])))))))\S+:\d+
      
    2. If the XML engine doesn’t support characters classes like \S and \d then use [^ \t\r\n\p] and [0-9] instead.

    Here is a running example: http://rubular.com/r/JnpCVgeLmL. Try changing the test string. You’ll see that…

        ab-proxy-sample.company.com:8080          # matches
        htab-proxy-sample.company.com:8080        # matches
        http://ab-proxy-sample.company.com:8080   # doesn't
        https://ab-proxy-sample.company.com:8080  # doesn't
        httpd://ab-proxy-sample.company.com:8080  # matches
    

    Note that you do not need the ^ and $. I added these specifically for the Rubular demo, but apparently the XML engine assumes this condition (anchored-ness).

    How does this work? It’s easier to understand if we break it up like this:

        ([^h] | h
        ([^t] | t
        ([^t] | t
        ([^p] | p
        ([^s:]| s ([^:]|:([^\/]|\/([^\/])))
              | :        ([^\/]|\/([^\/])))
        ))))
        \S+:\d+
    

    The explanation:

    1. If the first char isn’t an “h”, then great! (The string can’t possibly be “http://” or “https://”.)
    2. If the first char is an “h” though, then:
      1. If the second char isn’t a “t”, then great! (The string can’t possibly be “http://” or “https://”.)
      2. If the second char is a “t” though, then:
        1. … isn’t “t”, great!
        2. … is “t”, then:
          1. … isn’t “p”, great!
          2. … is “p”, then:

    Here, it gets tricky: now we encounter three branches.

    1. If the fifth char isn’t an “s” nor a “:”, then great!
    2. If the fifth char is an “s” though, then:
      1. If the sixth char isn’t a “:”, then great!
      2. If the sixth char is a “:” though, then:
        1. If the seventh char isn’t a “/”, then great!
        2. If the seventh char is a “/” though, then:
          1. If the eighth char isn’t a “/”, then great!
          2. Otherwise, fail! We found an “https://”.
    3. If the fifth char is a “:” though, then:
      1. If the sixth char isn’t a “/”, then great!
      2. If the sixth char is a “/” though, then:
        1. If the seventh char isn’t a “/”, then great!
        2. Otherwise, fail! We found an “http://”.

    And finally, if we’ve gotten this far, then we look for a string of non-whitespace characters, followed by a colon, followed by a string of digits.

    I leave it to a smarter mathematician than myself to ponder whether all strings matchable using lookarounds can be “brute-forced” in such a way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After having converted a messed up XML using regex, I now need to change
I am working on string maniplations using regex. Source: string value = @/webdav/MyPublication/Building%20Blocks/folder0/folder1/content_1.xml; output
I'm using a RegEx on an XML dump of a Wikipedia article. The Regex
I am attempting to fix some bilingual xml files using regular expressions to match
When using XML serialization in C#, I use code like this: public MyObject LoadData()
Been using XML for ages now for data storage & transfer, but have never
I'm using XML Serialization heavily in a web service (the contracts pass complex types
I'm using XML for a config file in PHP (Using SimpleXML), in creating the
I'm using XML Writer to create a log of some important events in my
I am using XML documentation headers on my c# files to pass the StyleCop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.