# Trimming an extended information field

**URL:** https://community.mp3tag.de/t/trimming-an-extended-information-field/65033
**Category:** Support
**Created:** [June 13, 2024, 3:51pm UTC](https://community.mp3tag.de/t/trimming-an-extended-information-field/65033 "2024-06-13T15:51:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Dotcom1970](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@Dotcom1970](https://community.mp3tag.de/u/Dotcom1970)
#### Post date: [June 13, 2024, 3:51pm UTC](https://community.mp3tag.de/t/trimming-an-extended-information-field/65033/1 "2024-06-13T15:51:15Z")

</div>

I've noticed when pulling album catalogue numbers from discogs, and displaying them in a custom field, sometimes they have more than one.

e;g: TICK001CD, TICK001CD, TICK001CD, TICK001CD

How can I create a reg expression to grab that first catalogue number where commas separate multiples?

Currently, my custom field is as follows:

Name: CATALOGNUMBER  
Value: $upper(%catalognumber%)  
Field: %catalognumber%

 ![example](https://community.mp3tag.de/uploads/default/original/3X/e/d/ed386a8198296210bcb34c69410c628b270ea6eb.png)

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [June 13, 2024, 3:59pm UTC](https://community.mp3tag.de/t/trimming-an-extended-information-field/65033/2 "2024-06-13T15:59:11Z")

</div>

You want to reduce multiple appearances of the same content in CATALOGNUMBER to one entry?

Or do you want the first entry only, ignoring what other contents follow?

---

<div class="post-metadata">

### Author: ![Dotcom1970](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@Dotcom1970](https://community.mp3tag.de/u/Dotcom1970)
#### Post date: [June 13, 2024, 4:01pm UTC](https://community.mp3tag.de/t/trimming-an-extended-information-field/65033/3 "2024-06-13T16:01:04Z")

</div>

In that pictured example, they are all the same, but in others, they may be different - all I want is the first listed.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [June 13, 2024, 4:18pm UTC](https://community.mp3tag.de/t/trimming-an-extended-information-field/65033/4 "2024-06-13T16:18:01Z")

</div>

You could adapt

> [@RegExp to extract text before first comma](https://community.mp3tag.de/t/regexp-to-extract-text-before-first-comma/57083/2):
>
> This is not quite true if you use $regexp(%composer%,'^(.+?),.\*',$1) instead The potential section following the comma does not necessarily need the parenthesis if you do not want to use it anyway, so $2 is not mandatory. ... but there are so many ways to solve the problem.

and use

`$regexp(%CATALOGNUMBER%,'^(.+?),.*',$1)`

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [June 13, 2024, 4:24pm UTC](https://community.mp3tag.de/t/trimming-an-extended-information-field/65033/5 "2024-06-13T16:24:56Z")

</div>

BTW:  
The term "trimming" as used in your title question is not exactly what you want to do.

"Trimming" in the [scripting](https://docs.mp3tag.de/scripting/#string-functions) world means "to cut away leading or trailing whitespaces":

 ![image](https://community.mp3tag.de/uploads/default/original/3X/9/c/9c67b005490c14c6af780e7fe7aeff7821a56321.png)

---

<div class="post-metadata">

### Author: ![Dotcom1970](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@Dotcom1970](https://community.mp3tag.de/u/Dotcom1970)
#### Post date: [June 13, 2024, 4:31pm UTC](https://community.mp3tag.de/t/trimming-an-extended-information-field/65033/6 "2024-06-13T16:31:13Z")

</div>

Apologies for using the wrong term. I'm very much a novice at this.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [July 13, 2024, 4:31pm UTC](https://community.mp3tag.de/t/trimming-an-extended-information-field/65033/7 "2024-07-13T16:31:56Z")

</div>

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