# How can I get parts from a tag using regex and add them to an other?

**URL:** <https://community.mp3tag.de/t/how-can-i-get-parts-from-a-tag-using-regex-and-add-them-to-an-other/55823>\
**Category:** Support\
**Created:** [January 9, 2022, 4:31pm UTC](https://community.mp3tag.de/t/how-can-i-get-parts-from-a-tag-using-regex-and-add-them-to-an-other/55823 "2022-01-09T16:31:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simos\_Sigma](https://community.mp3tag.de/user_avatar/community.mp3tag.de/simos_sigma/32/9966_2.png) [@Simos\_Sigma](https://community.mp3tag.de/u/Simos_Sigma)\
**Post date:** [January 9, 2022, 4:31pm UTC](https://community.mp3tag.de/t/how-can-i-get-parts-from-a-tag-using-regex-and-add-them-to-an-other/55823/1 "2022-01-09T16:31:31Z")

</div>

Greetings to community!!!

What I am trying to do is to get some **parts** from **comment tag** and add them to some **custom tags**. For example, I have a track with this comment tag " **Real Bitrate: 320 | Spectrum Frequency: 20045 |**" and I want to get only the number **320** and **20045** and add them to " **Real Bitrate**" and " **Spectrogram**" **custom tags**. Can someone help me on how to do this? Any regex example or something?

Thank you for your time!!!

---

<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:** [January 9, 2022, 5:01pm UTC](https://community.mp3tag.de/t/how-can-i-get-parts-from-a-tag-using-regex-and-add-them-to-an-other/55823/2 "2022-01-09T17:01:46Z")

</div>

If you have your values 320 and 20045 always separated with a space before and after the numbers, you can use this new Action:

Type: Format value  
Field: REAL BITRATE  
Format String:  
`$regexp(%comment%,'.* (\d+) .* (\d+) .*',$1)`

![image](https://community.mp3tag.de/uploads/default/original/2X/1/1a07fa941d7af2a51afc59d477d23f96a77e440c.png)

Repeat it for Spectrogram and use the  
Field: SPECTROGRAM  
Format String:  
`$regexp(%comment%,'.* (\d+) .* (\d+) .*',$2)`

Short explanation for the regular expression:  
Search in the %comment% tag for  
anything before a space followed by opening bracket, numbers and followed by a closing bracket  
a space  
anything before a space followed by opening bracket, numbers and followed by a closing bracket  
a space  
anything else  
The first found number will be available in `$1`, the second number in `$2`

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [January 9, 2022, 5:03pm UTC](https://community.mp3tag.de/t/how-can-i-get-parts-from-a-tag-using-regex-and-add-them-to-an-other/55823/3 "2022-01-09T17:03:35Z")

</div>

Or in one go:  
Try an action of the type "Guess value" (import tag fields).  
Source: `$regexp(%comment%,'.* (\d+) .* (\d+) .*',$1==$2)`  
Target format string: %REAL BITRATE%==%SPECTROGRAM%

---

<div class="post-metadata">

**Author:** ![Simos\_Sigma](https://community.mp3tag.de/user_avatar/community.mp3tag.de/simos_sigma/32/9966_2.png) [@Simos\_Sigma](https://community.mp3tag.de/u/Simos_Sigma)\
**Post date:** [January 9, 2022, 5:25pm UTC](https://community.mp3tag.de/t/how-can-i-get-parts-from-a-tag-using-regex-and-add-them-to-an-other/55823/4 "2022-01-09T17:25:28Z")

</div>

Thank you both for your answers, your really helped me!!! 🙂

---

<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:** [February 8, 2022, 5:25pm UTC](https://community.mp3tag.de/t/how-can-i-get-parts-from-a-tag-using-regex-and-add-them-to-an-other/55823/5 "2022-02-08T17:25:44Z")

</div>

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