# 'Format Value' behavior with Unmatched $regexp

**URL:** <https://community.mp3tag.de/t/format-value-behavior-with-unmatched-regexp/16300>\
**Category:** Support\
**Created:** [November 7, 2014, 10:15pm UTC](https://community.mp3tag.de/t/format-value-behavior-with-unmatched-regexp/16300 "2014-11-07T22:15:29Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![musicdemon](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@musicdemon](https://community.mp3tag.de/u/musicdemon)\
**Post date:** [November 7, 2014, 10:15pm UTC](https://community.mp3tag.de/t/format-value-behavior-with-unmatched-regexp/16300/1 "2014-11-07T22:15:29Z")

</div>

I'm going through my classical music collection and adding values for my custom OPUS field. I'd like to be able to use a custom Action to add the Opus number to the Opus field, but **only if the opus number exists** in the title. Here's the custom action I'm currently using:

Field: OPUS  
Format Value: $regexp(%title%,'(._Opu?s?.?\s?)(\d+)._',$2)

This works fine, when there is an opus number in the title. However, when there's a regular title like so, this action just assigns the title to the Opus field, instead of leaving it null. Example:

Before Action:  
Title = Tragic Overture  
Opus = _null_

After Action:  
Title = Tragic Overture  
Opus = Tragic Overture

I'd like to be able to use this on all my tracks, without having to visually check if it exists for each track before running my custom action. Is there a way to only perform the replace if the RegEx matches?

---

_[View the full topic](https://community.mp3tag.de/t/format-value-behavior-with-unmatched-regexp/16300)._
