# Assistance required to locate a specific segment inside various text strings

**URL:** <https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072>\
**Category:** Support\
**Created:** [May 26, 2023, 10:14am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072 "2023-05-26T10:14:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [May 26, 2023, 10:14am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/1 "2023-05-26T10:14:19Z")

</div>

Hello, everyone.

The following is an example of the string of text which I have to work on:

**(wfrank)**

Actual working examples of album titles are:

Cara Mia (wChorus & Mantovani & His Orchestra)  
Rock And Roll Waltz (wThe Hugo Winterhalter)

The string of text that needs editing, usually appears in the TITLE, ARTIST and the \_FILENAME fields.

There are the three constants in the aforesaid strings:

1. The opening bracket
2. The closing bracket
3. The letter "w" that immediately follows the opening bracket.

The letter "w" appears in lower case, _although there are exceptions_ which are capitalised. There is no space inbetween the "w" and the leters immediately following, until the closing bracket. The text following the "w" can also vary considerably in length and form.

I am seeking your assistance, please, for a filter to apply to locate those files that match the opening bracket plus the lower case "w" (OR capital "W") in the %title%, %artist% and %\_filename% fields. My own efforts at this came adrift using this, for example, for the %title% field:

`%title% MATCHES \(w`  
`%title% MATCHES \(w[w]`

Once the relevant files are found, what would be the best way to restructure the applicable string to this —

**From: (wfrank) to (With Frank)**

That is, capitalise the W that follows the opening bracket, followed by a space, and then capitalise the first letter directly following this space.

I did make a Format Value action group for the three abovementioned fields that looks like this, and it is working, but I want to know if it holds any pitfalls which I should be aware of:

`$replace(%title%,'(w','(With ',)`

Thank you.

---

<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:** [May 26, 2023, 10:27am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/2 "2023-05-26T10:27:58Z")

</div>

To filter for file with `(w` and a bracket followed by a lower case character followed by an upper case letter, try:  
`%title% MATCHES "\(\l\u" AND %title% HAS "(w"`  
or even  
`%title% MATCHES "\(.\u" AND %title% HAS "(w"`

> [@ragtag](#):
>
> `$replace(%title%,'(w','(With ',)`

should be  
`$replace(%title%,'(w','(With ')`

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [May 26, 2023, 10:43am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/3 "2023-05-26T10:43:31Z")

</div>

@ohrenkino

Thank you, am going to apply it shortly.

> [@ohrenkino](#):
>
> $replace(%title%,'(w','(With ')

Question: is the last comma always superflous, and therefore should be dropped?

---

<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:** [May 26, 2023, 10:46am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/4 "2023-05-26T10:46:57Z")

</div>

Where did you get the idea of a trailing comma?  
The documentation says:  
`$replace(x,y,z)` returns the string x with all occurrences of string y replaced by string z. Supports multiple parameter pairs y and z.

Taken from

> **[Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/)**
>
> Documentation on Mp3tag's scripting functions. Mp3tag is the universal Tag Editor.

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [May 26, 2023, 11:01am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/5 "2023-05-26T11:01:53Z")

</div>

Thanks for pointing that out. (I can't recall anymore why I am using it, since I have been using it for years just like that, and did not notice any ill effect due to it. At first, it did look out-of-place, but, sadly, I was none the wiser, because it did deliver the desired results.)

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [May 26, 2023, 11:34am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/6 "2023-05-26T11:34:09Z")

</div>

> [@ohrenkino](#):
>
> To filter for file with `(w` and a bracket followed by a lower case character followed by an upper case letter, try:  
> `%title% MATCHES "\(\l\u" AND %title% HAS "(w"`  
> or even  
> `%title% MATCHES "\(.\u" AND %title% HAS "(w"`

Sorry, I may have expressed myself poorly. The above currently filters the following, example:

Nancy (With The Laughing Face)

Instead of what is required. Here are more examples where the text segment marked in bold type, that needs to be filtered.

Nancy **(w**The Laughing Face)  
Nancy **(W**The Laughing Face)  
Nancy **(w**the Laughing Face)  
Nancy **(W**the Laughing Face)  
Nancy **(w**frank)  
Nancy **(W**Frank)  
Nancy **(w**Frank)  
Nancy **(W**frank)

To be replaced with, example:

Nancy (With\_The Laughing Face) — where the underscore represents a space.

---

<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:** [May 26, 2023, 11:38am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/7 "2023-05-26T11:38:16Z")

</div>

Please try:  
`%title% MATCHES "(?-i)\(.\u" AND %title% HAS "(w"`

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [May 26, 2023, 11:52am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/8 "2023-05-26T11:52:47Z")

</div>

> [@ohrenkino](#):
>
> %title% MATCHES "(?-i)(.\u" AND %title% HAS "(w"

It DID work just fine, **thank you** @ohrenkino.

---

<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 25, 2023, 11:53am UTC](https://community.mp3tag.de/t/assistance-required-to-locate-a-specific-segment-inside-various-text-strings/61072/9 "2023-06-25T11:53:07Z")

</div>

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