# How to prevent duplicate tags in Websources Script?

**URL:** https://community.mp3tag.de/t/how-to-prevent-duplicate-tags-in-websources-script/56417
**Category:** Web Sources Discussion
**Created:** [February 21, 2022, 9:10am UTC](https://community.mp3tag.de/t/how-to-prevent-duplicate-tags-in-websources-script/56417 "2022-02-21T09:10:00Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![yorickausyps](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/f6c823/32.png) [@yorickausyps](https://community.mp3tag.de/u/yorickausyps)
#### Post date: [August 4, 2025, 9:05am UTC](https://community.mp3tag.de/t/how-to-prevent-duplicate-tags-in-websources-script/56417/5 "2025-08-04T09:05:34Z")

</div>

The deduplication for e.g. names in a list can be done in a websource script in the following way.

Before we store the new name in the output buffer `“soloist”` containing the list of names we have to check if it is already in this output buffer.  
The command `findinline` seems to do right that, but unfortunately it works the other way around: It finds a given string in the current input line. Because we are searching for a string in another output buffer, we first have to exchange the contents of the two buffers.  
We store the new name into in a temporary used output buffer `“temp_name”` and then load the content of the output buffer `“soloist”` with the command `regexpreplace "^.*" "%soloist%"` in the current input line.  
But two more things have to be taken care of:  
To actually test if the command `findinline` has found a match we mark the end of the line with a vertical bar `|` and to avoid a substring to trigger a match we have to enclose the strings with our delimiter `\\`.  
Your example now can be extended like that:

```auto
set "SOLOIST" 
json_select "artist"
json_foreach "artist"
   json_select "name"
      set "temp_name"
      outputto "temp_name"
      SayRest
      regexpreplace "^.*" "\\\\%soloist%\\\\|"
      findinline "\\%temp_name%\\" 1 1
      movechar -1
      if "|"
         outputto "soloist"
         ifoutput "soloist"
            say "\\\\"
         endif
         sayoutput "temp_name"
      endif
json_foreach_end

```

It uses the new feature available since version 3.23 to reference contents of output buffers via `%output%` in all string parameters.  
The "feature" to overload the input line with the `regexreplace "^.*" "string"` is very valuable for writing websource scripts, that do "currently impossible" things.

Hope this helps.

PS The number of backslashs was not correct. Thanks to [Output referral and special characters - #2 by rboss](https://community.mp3tag.de/t/output-referral-and-special-characters/67947/2)

---

_[View the full topic](https://community.mp3tag.de/t/how-to-prevent-duplicate-tags-in-websources-script/56417)._
