473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

A little regex help?

Man I suck at regex.

How do I write a regex that matches http://att.com and http://www.att.com
but doesn't match http://matt.com or http://www.bratt.com?

I'm trying to create a whitelist but I keep ending up with sites I don't
want matching my criteria.

I just can't seem to get my head around it.

Any help would be appreciated.
Mar 27 '07 #1
3 1125
On Mar 27, 12:33 pm, Ivan Marsh <anno...@you.nowwrote:
Man I suck at regex.

How do I write a regex that matcheshttp://att.comandhttp://www.att.com
but doesn't matchhttp://matt.comorhttp://www.bratt.com?

I'm trying to create a whitelist but I keep ending up with sites I don't
want matching my criteria.

I just can't seem to get my head around it.

Any help would be appreciated.
check out the following site. It helped me out a lot.
http://www.anaesthetist.com/mnm/perl/regex.htm

Mar 27 '07 #2
On Mar 27, 10:33 am, Ivan Marsh <anno...@you.nowwrote:
Man I suck at regex.

How do I write a regex that matches http://att.com and http://www.att.com
but doesn't match http://matt.com or http://www.bratt.com ?

/^http:\/\/(w{3}\.)?att\.com/i
Mar 27 '07 #3
scripts.contact wrote:
On Mar 27, 10:33 am, Ivan Marsh <anno...@you.nowwrote:
>Man I suck at regex.

How do I write a regex that matches http://att.com and http://www.att.com
but doesn't match http://matt.com or http://www.bratt.com ?


/^http:\/\/(w{3}\.)?att\.com/i
I highly recommend the following app, it helped me a lot in allowing to
paste in text and then check regex expressions against the text quickly:

http://weitz.de/regex-coach/
Mar 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ivan Marsh | last post by:
Hey Folks, This isn't actually a perl question but since you folks ar the regex experts I thought you might be able to help. I want to do a search and replace in my text editor (that supports...
4
by: Garibaldi | last post by:
Folks, I'm having a bad regex day and can sure use your help, please.. I have a Regex expression that works fine. It's purpose is to isolate all data from the start of a string begining with...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
7
by: Mike Labosh | last post by:
I have the following System.Text.RegularExpressions.Regex that is supposed to remove this predefined list of garbage characters from contact names that come in on import files : Dim...
6
by: MatsL | last post by:
Hi, I saw that some other people posted questions about regular expressions here so I thought I would do the same. I'm trying to parse an url to different parts. I want the file name and path to...
9
by: jmchadha | last post by:
I have got the following html: "something in html ... etc.. city1... etc... <a class="font1" href="city1.html" onclick="etc."click for <b>info</bon city1 </a> ... some html. city1.. can repeat...
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
6
by: Phil Barber | last post by:
I am using Regex to validate a file name. I have everything I need except I would like the dot(.) in the filename only to appear once. My question is it possible to allow one instance of character...
1
by: jonnyboy6969 | last post by:
Hi All Really hoping someone can help me out here with my deficient regex skills :) I have a function which takes a string of HTML and replaces a term (word or phrase) with a link. The pupose...
0
by: Support Desk | last post by:
That’s it exactly..thx -----Original Message----- From: Reedick, Andrew Sent: Tuesday, June 03, 2008 9:26 AM To: Support Desk Subject: RE: regex help The regex will now skip anything with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.