# Regex for repeat words

**URL:** <https://community.glideapps.com/t/regex-for-repeat-words/59692>\
**Category:** Ask for Help\
**Created:** [March 26, 2023, 2:19am UTC](https://community.glideapps.com/t/regex-for-repeat-words/59692 "2023-03-26T02:19:07Z")\
**Posts on this page:** 6\
**Page:** 3

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [March 26, 2023, 4:31pm UTC](https://community.glideapps.com/t/regex-for-repeat-words/59692/41 "2023-03-26T16:31:07Z")

</div>

Nope, not working.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [March 26, 2023, 4:32pm UTC](https://community.glideapps.com/t/regex-for-repeat-words/59692/42 "2023-03-26T16:32:32Z")

</div>

It works… it will show you the number of matches.

 ![Screen Shot 2023-03-26 at 12.42.53 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/d/4d07ad2754b84c2cf3670269b99c20eba6aeff53.jpeg)

```auto
if(p1){
var res=0;
var string = p1.replace(/\s*-\s*/g, "-");
var split = string.split(' ');
var dash = split.filter(word => word.includes("-"));
for (let i = 0; i < dash.length; i++) {
  var splitDash = dash[i].split('-');
  if(splitDash[0].toLowerCase() === splitDash[1].toLowerCase()){
    if(splitDash[1].toLowerCase() === splitDash[1]){
      res=res+1;
    }
  }
}
return res;
}

```

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [March 26, 2023, 4:41pm UTC](https://community.glideapps.com/t/regex-for-repeat-words/59692/43 "2023-03-26T16:41:53Z")

</div>

Why are you crunching the numbers, I didn’t ask for it. 😉 I’ll save it, it might come in handy someday.  
Why are your script and image different but working?

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [March 26, 2023, 4:43pm UTC](https://community.glideapps.com/t/regex-for-repeat-words/59692/44 "2023-03-26T16:43:53Z")

</div>

How else are you going to show multiple?

if you don’t need to show count… then replace res=“TRUE”  
As I said… is hard to guess what you need because I don’t know your purpose…  
If you explain the flow in the beginning… you will have a code in 10 min… 😉  
it took me a long time to understand what you need… and I guess… I still don’t get it.

(I replaced the image with a matching one, I adjusted the script, to eliminate global variables, and error on empty input)

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [March 26, 2023, 4:49pm UTC](https://community.glideapps.com/t/regex-for-repeat-words/59692/45 "2023-03-26T16:49:16Z")

</div>

Nice, you are great. ✌

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [March 27, 2023, 4:50pm UTC](https://community.glideapps.com/t/regex-for-repeat-words/59692/46 "2023-03-27T16:50:07Z")

</div>

Closed on March 27, 2023, 4:50pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

[Previous page](https://community.glideapps.com/t/regex-for-repeat-words/59692.md?page=2)
