Retain the first 10 characters and delete everything after

Currently, I have the following pattern for my filenames (these are some examples):

1981-03-01-Kim Carnes-Bette Davis Eyes.mp3
1981-07-01-Soft Cell-Tainted Love.mp3
1982-01-22-Huey Lewis and The News-Do You Believe in Love.mp3
1982-06-01-Laura Branigan-Gloria.mp3

My YEAR field is blank. I would like for my YEAR field to become:

YYYY-MM-DD

Thus, for example, if this is my filename:

1981-03-01-Kim Carnes-Bette Davis Eyes

I want my YEAR field to go from blank to:

1981-03-01

Therefore, I would like to do a filename to tag conversion, where I keep the first 10 characters of the filename, and delete all characters after position 10, and this result becomes my YEAR field. The number of characters that need to be deleted after position 10 is variable, as can be seen in the above examples, but retaining the first 10 characters is always a constant. I've seen some examples where a specified number of leading characters are DELETED (for example, deleting the first ten leading characters: ^.{10}) and everything else after that is retained, but I need the other way around. And I don't think I can specify a certain number of TRAILING characters to be deleted because the number of trailing characters to be deleted (as noted above) is variable.

I couldn't figure out how to do this with %guess% (guess values) because there are dashes in the YYYY-MM-DD syntax but also dashes in the rest of the expression. The delimiter (the dash) immediately following YYYY-MM-DD isn't unique and occurs within the characters that I want to keep.

For example, I tried this:

Convert
Filename - Tag
Format String: %year% %guess%

The result:

Filename: 1981-03-01-Kim Carnes-Bette Davis Eyes.mp3
YEAR: 1981-03-01-Kim

I also tried to figure out how to do this with a regular expression (regexp) - retain first 10 characters and remove everything thereafter. I found something on a general regular expression discussion forum (not mp3tag) regarding "how to remove all but the first n characters", and from looking over that I wondered if something like this might do it in mp3tag in 2 steps:

Step 1
Convert
Filename - Tag
Format String: %YEAR%

Step 2
Action:
Replace with regular expression
Field: %YEAR%
Regular expression: $regexp(^(.{10}).*$)
Replace matches with: \1

However, even if this "replace with regular expression" approach is on the right path, I don't think I have the correct syntax because I don't understand regular expression syntax very well in general. The above action (Step 2) did not work; nothing changed.

Perhaps this is much easier than I am making it and can be done rather simply without regexp?

Any assistance is appreciated.

You could try an action of the type "Format value" or Convert>Tag-Tag for YEAR
Format string: $regexp(%_filename%,(.*?)-\u.*,$1)

Please note that the field YEAR is supposed to have only 4 digits according to the ID3 standard.
If you want to use such a longer date, consider the use of RELEASETIME

You could simply shorten that longer date for the use in YEAR.

Thanks very much for the prompt reply! That works perfectly.

Here is what I did:

Step 1
Convert
Filename - Tag
Format String: %YEAR%

Step 2
Convert
Tag - Tag
Field: YEAR
Format string:
$regexp(%_filename%,(.*?)-\u.*,$1)

Thanks for the info regarding the ID3 standard for YEAR being only 4 digits. I'll consider using RELEASETIME for my YYYY-MM-DD date with YEAR being just the four-digit year.

TBH, step 1 is not really necessary, as you overwrite YEAR with step 2.
Use step2 as step1 but not for YEAR but for RELEASETIME.
Create a new step 2 with an action of the type "Format value" or use Convert>Tag-Tag for YEAR
Format string: $num(%releasetime%,1)
this should strip the first part from RELEASETIME up to the first non-digit character which is the hyphen.

Thank you! I practiced your 2-step procedure for RELEASETIME and YEAR and it works great. And I see why your original solution does not require two steps as I had at first thought; I practiced that as well and successfully did the TAG-TAG conversion in 1 step to fill the blank YEAR field from the first 10 characters of filename.

Here is my summary of the two procedures:

Procedure 1: Put YYYY-MM-DD in YEAR field from first 10 characters of filename:
-1 step
-however, doesn't comply with 4-digit ID3 standard for YEAR field

Convert
Tag - Tag
Field: YEAR
Format string: $regexp(%_filename%,(.*?)-\u.*,$1)

Procedure 2: Put YYYY-MM-DD in RELEASETIME and YYYY in YEAR:
-2 steps
-complies with 4-digit ID3 standard for YEAR field

Step 1
Convert
Tag - Tag
Field: RELEASETIME
Format string: $regexp(%_filename%,(.*?)-\u.*,$1)

Step 2
Convert
Tag - Tag
Field: YEAR
Format string: $num(%releasetime%,1)