# Replacing first occurence of character with something else

**URL:** <https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771>\
**Category:** Support\
**Created:** [February 6, 2018, 1:00am UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771 "2018-02-06T01:00:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![macakcira](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/d78d45/32.png) [@macakcira](https://community.mp3tag.de/u/macakcira)\
**Post date:** [February 6, 2018, 1:00am UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/1 "2018-02-06T01:00:33Z")

</div>

Hey guys,

I have a bunch of files with TITLE fields like this: 123 cute kittens

I would like to make them look like this: 123 - cute kittens

I tried to play with replace and guess values but it either changes all spaces or changes nothing - because I have no idea what I'm doing 😃

So, if any of you experts can share a help i'd appreciate it 🙂

---

<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:** [February 6, 2018, 5:11am UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/2 "2018-02-06T05:11:25Z")

</div>

If the 123 is always a number, then you could try an action of the type "Replace with regular expression for TITLE:  
Search string: `(\d+)`  
Replace string: `$1 -`

---

<div class="post-metadata">

**Author:** ![macakcira](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/d78d45/32.png) [@macakcira](https://community.mp3tag.de/u/macakcira)\
**Post date:** [February 6, 2018, 10:27am UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/3 "2018-02-06T10:27:37Z")

</div>

> [@ohrenkino](#):
>
> If the 123 is always a number, then you could try an action of the type "Replace with regular expression for TITLE:  
> Search string: `(\d+)`  
> Replace string: `$1 -`

Hello,

actually it's a mix of numbers and letters like this 1m01b, and that is not always the same but is always made of mix of letters and numbers with space at the end, thats why i thought of focusing on first occurance of space (if that is possible)...

---

<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:** [February 6, 2018, 11:50am UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/4 "2018-02-06T11:50:18Z")

</div>

> [@macakcira](#):
>
> Hello,
> 
> actually it's a mix of numbers and letters like this 1m01b, and that is not always the same but is always made of mix of letters and numbers with space at the end, thats why i thought of focusing on first occurance of space (if that is possible)...

`$regexp(%title,(.*?)( .*) ,$1 -$2)`  
(this should work in an action of the type "FOrmat value" as format string)

---

<div class="post-metadata">

**Author:** ![macakcira](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/d78d45/32.png) [@macakcira](https://community.mp3tag.de/u/macakcira)\
**Post date:** [February 6, 2018, 12:30pm UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/5 "2018-02-06T12:30:29Z")

</div>

> [@ohrenkino](#):
>
> `$regexp(%title,(.*?)( .*) ,$1 -$2)`  
> (this should work in an action of the type "FOrmat value" as format string)

It's working, but now the last two words get glued together. Like before there was a space between them, but now there isn't..

---

<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:** [February 6, 2018, 1:35pm UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/6 "2018-02-06T13:35:30Z")

</div>

> [@macakcira](#):
>
> It's working, but now the last two words get glued together. Like before there was a space between them, but now there isn't..

I think you need a space right before the last bracket (for some reason this did not translate into the post when I copied and pasted it ...)  
`$regexp(%title%,(.*?)( .*) ,$1 -$2_)`  
the \_ indicating the space character

---

<div class="post-metadata">

**Author:** ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)\
**Post date:** [February 6, 2018, 1:38pm UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/7 "2018-02-06T13:38:55Z")

</div>

Examples:

`$regexp('123 abc def','(.+?) (.+)','$1 - $2')`  
==\> '123 - abc def'

`$regexp('abc def','(.+?) (.+)','$1 - $2')`  
==\> 'abc - def'

`$regexp('abc','(.+?) (.+)','$1 - $2')`  
==\> 'abc'

DD.20170206.1538.CET

---

<div class="post-metadata">

**Author:** ![macakcira](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/d78d45/32.png) [@macakcira](https://community.mp3tag.de/u/macakcira)\
**Post date:** [February 6, 2018, 1:54pm UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/8 "2018-02-06T13:54:34Z")

</div>

Guys thank you so much, it's working flawlessly! What a great forum!

---

<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:** [June 17, 2023, 10:04pm UTC](https://community.mp3tag.de/t/replacing-first-occurence-of-character-with-something-else/19771/9 "2023-06-17T22:04:46Z")

</div>

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