# Can my $regexp() code be made any better?

**URL:** https://community.mp3tag.de/t/can-my-regexp-code-be-made-any-better/69024
**Category:** Mac
**Created:** [July 2, 2025, 9:11pm UTC](https://community.mp3tag.de/t/can-my-regexp-code-be-made-any-better/69024 "2025-07-02T21:11:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Erichwanh](https://community.mp3tag.de/user_avatar/community.mp3tag.de/erichwanh/32/19236_2.png) [@Erichwanh](https://community.mp3tag.de/u/Erichwanh)
#### Post date: [July 2, 2025, 9:11pm UTC](https://community.mp3tag.de/t/can-my-regexp-code-be-made-any-better/69024/1 "2025-07-02T21:11:49Z")

</div>

I was wondering if my code can be streamlined any more than it is. Quick background:

- I'm writing actions to read and write cuesheet \<-\> tags. My current, albeit unfinished, code works, so if nothing changes, that's 100% Ok. I'm just looking to learn 8^)

I notice that when I use, for example, $regexp(%TAG%,'(string)', $1), if the string isn't found, the action returns TAG in full. So, when I search for a string to pull a piece of info for tag, I do this:

Field: DUMMY  
Format: $regexp(%CUESHEET2%,'.\*?REM BOXSETYEAR "(.+?)".+',$1)  
Field: BOXSETYEAR  
Format: $if($eql(%DUMMY%,%CUESHEET2%),,%DUMMY%)

Like I said, the code does what I want, so it doesn't need to change. But is there any way to make it more efficient?

If you've read this far, thank you kindly for your time 8^)

---

<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: [July 3, 2025, 12:19pm UTC](https://community.mp3tag.de/t/can-my-regexp-code-be-made-any-better/69024/2 "2025-07-03T12:19:46Z")

</div>

You could try a different action type: Import tag fields  
Source string: %cuesheet2%  
Import pattern: `%dummy%REM BOXSETYEAR "%boxsetyear%" %dummy%`

---

<div class="post-metadata">

### Author: ![Erichwanh](https://community.mp3tag.de/user_avatar/community.mp3tag.de/erichwanh/32/19236_2.png) [@Erichwanh](https://community.mp3tag.de/u/Erichwanh)
#### Post date: [July 3, 2025, 9:56pm UTC](https://community.mp3tag.de/t/can-my-regexp-code-be-made-any-better/69024/3 "2025-07-03T21:56:55Z")

</div>

Hah! That's how you use that action. That streamlines things considerably, thank you kindly.

---

<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: [August 2, 2025, 9:57pm UTC](https://community.mp3tag.de/t/can-my-regexp-code-be-made-any-better/69024/4 "2025-08-02T21:57:33Z")

</div>

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