# Regex to detect domain name mismatches

**URL:** https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826
**Category:** Technical Support
**Created:** [October 10, 2021, 1:56pm UTC](https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826 "2021-10-10T13:56:32Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![LuisHermogenes](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@LuisHermogenes](https://forum.xbench.net/u/LuisHermogenes)
#### Post date: [October 10, 2021, 1:56pm UTC](https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826/1 "2021-10-10T13:56:32Z")

</div>

Hi all,

I am trying to create a regular expression that would detect an exact mismatch of a domain name between source and target.

For instance, I have “[sitename.com](http://sitename.com)”, “[sitename.de](http://sitename.de)”, “sitename.com.ca”, and “sitename.com.mx”.  
I can easily enough find any mismatches to mismatches where “[sitename.com](http://sitename.com)” is not used.  
For example, this detects if “[sitename.de](http://sitename.de)” is used in the source and not in the target:

Source: “((sitename.[a-z]{1,3})=1”  
Target: -@1

However, because the last two (“sitename.com.ca” and “sitename.com.mx”) have “.com” in the name, Xbench considers them a match (even if I select “Match whole word” or I use the “End of word” regex (e.g., “sitename.[a-z]{1,3}\>”).)

I’ve tried even creating a Key term list with the domain names, but it seems Xbench considers the second period (“sitename.com.XX”) the end of the word, so it is thinks “[sitename.com](http://sitename.com)” is the full match.

Any help here? Thanks!

---

<div class="post-metadata">

### Author: ![omartin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.xbench.net/omartin/32/82_2.png) [@omartin](https://forum.xbench.net/u/omartin)
#### Post date: [October 10, 2021, 9:49pm UTC](https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826/2 "2021-10-10T21:49:15Z")

</div>

Hi Luis,

I would use the following regex to find all those domain names:

Source: `"(sitename((\.[a-z]+))+)=1"`  
Target: `-@1`

Search mode: regular expressions  
Match Whole Word and PowerSearch: on.

By the way, replace sitename with the domain you want to find.

An alternative to get all site names, would be to change the source term to `"([a-z0-9\-]{1,63}((\.[a-z]+))+)=1"`

However, you may get too many false errors.

I hope this helps.

Best regards,  
Oscar.

---

<div class="post-metadata">

### Author: ![LuisHermogenes](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@LuisHermogenes](https://forum.xbench.net/u/LuisHermogenes)
#### Post date: [October 11, 2021, 8:17am UTC](https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826/3 "2021-10-11T08:17:02Z")

</div>

Hi Óscar,

Thanks for your quick reply! However, the issue is still happening.  
It does not detect an issue when the source is “[sitename.com](http://sitename.com)” and target is “sitename.com.ca”, for instance. I think it is because Xbench does not read “sitename.com.ca” as a single full word, but instead reads it as 3 words (sitename, com, and ca); as it considers the period a parsing character.

What can we do?

---

<div class="post-metadata">

### Author: ![omartin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.xbench.net/omartin/32/82_2.png) [@omartin](https://forum.xbench.net/u/omartin)
#### Post date: [October 11, 2021, 8:44am UTC](https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826/4 "2021-10-11T08:44:12Z")

</div>

The following search works fine:

Source: `"(sitename(\.[a-z]+)+)=1"`  
target: `-@1`

Search mode: regular expressions  
Match Whole Word and PowerSearch: on.

 ![2021-10-11_10h42_27](https://canada1.discourse-cdn.com/flex035/uploads/xbench/original/1X/2687b1656da7b411513d87bbabd6380da8fca08e.png)

---

<div class="post-metadata">

### Author: ![LuisHermogenes](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@LuisHermogenes](https://forum.xbench.net/u/LuisHermogenes)
#### Post date: [October 11, 2021, 9:51am UTC](https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826/5 "2021-10-11T09:51:59Z")

</div>

Hi Oscar,

Sure, but I mean the other way around. It will detect when “sitename.com.ca” is in source and not in target appears, but not the other way around.

I tried reverting the expression, and it works:

Source: -@1  
target: “(sitename(.[a-z]+)+)=1”

Can you help me confirm this would detect the same issues as in the one you showed me above? I.e.:

Source: “(sitename(.[a-z]+)+)=1”  
target: -@1

EDIT: Meaning, would it detect all issues of mismatches in source and target?

Thanks!

---

<div class="post-metadata">

### Author: ![omartin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.xbench.net/omartin/32/82_2.png) [@omartin](https://forum.xbench.net/u/omartin)
#### Post date: [October 11, 2021, 10:19am UTC](https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826/6 "2021-10-11T10:19:06Z")

</div>

> [@LuisHermogenes](#):
>
> Source: “(sitename(.[a-z]+)+)=1”  
> target: -@1

This search will detect all segments that contain a domain name in source but is missing in the target.

You should create a checklist entry for each search.

---

<div class="post-metadata">

### Author: ![LuisHermogenes](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@LuisHermogenes](https://forum.xbench.net/u/LuisHermogenes)
#### Post date: [October 11, 2021, 10:42am UTC](https://forum.xbench.net/t/regex-to-detect-domain-name-mismatches/826/7 "2021-10-11T10:42:14Z")

</div>

Hi Oscar.  
Got it, I’ll create two searches, one for missing in source and one for missing in target.

Thanks!
