Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression

Status
Not open for further replies.

thoxin

Programmer
Jun 5, 2001
11
0
0
DE
Hello,

Perl is quite new to me and I don´t have much experience with regular Expressions.
But now I need one to match this Pattern.


I need the '.domain.top' information. Can someone help me with this expression?

Thanks
Thomas
 
hi,

thank but I was looking for this one.

(\.[a-z0-9-])(\.[a-z0-9-])$

regards
thomas
 
probably better:
Code:
@strings = (
  "[URL unfurl="true"]www.tek-tips.com",[/URL]
  "server1.mps.ond-43.silvernet.org",
  "esdn3.over-wash-ibm-corp.nns2.solutions.net",
  "super.size.mcdonalds.com"
  );

for(@strings){
  local $\ = "\n";
  /\.\w+\.\w+$/;
  print $&;
}

This will always ouput the two topest level domains, regardless of the number of subdomains.

--jim
 
oops. posted at the same time as thomas. didn't see his till afterwards.
 
no, mine is wrong becuase I don't include dashes as valid characters... modified:

/\.[\w-]+\.[\w-]+$/;
 
OOPS I did't include dashes as valid characters... modified:

/\.[\w-]+\.[\w-]+$/;

Glad I could assist.

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top