# Regexpreplace '.\*' 'OK' matches twice

**URL:** https://community.mp3tag.de/t/regexpreplace-ok-matches-twice/62436
**Category:** Web Sources Discussion
**Created:** [October 17, 2023, 9:06am UTC](https://community.mp3tag.de/t/regexpreplace-ok-matches-twice/62436 "2023-10-17T09:06:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![yorickausyps](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/f6c823/32.png) [@yorickausyps](https://community.mp3tag.de/u/yorickausyps)
#### Post date: [October 17, 2023, 9:06am UTC](https://community.mp3tag.de/t/regexpreplace-ok-matches-twice/62436/1 "2023-10-17T09:06:33Z")

</div>

For testing the new websource script options setting feature i wanted to define a filter for the format of an album:

```auto
{
      "type": "string",
      "key": "FilterFormat",
      "title": "Media Format",
      "description": "Filter used for Media Format.",
      "choices": [
	    "Any",
		"Cassette",
        "CD",
		"DVD",
		"File",
        "Vinyl"
      ],
      "default": "Any"
    },

```

If I use in ParserScriptIndex

```auto
		json_select_array "format" -1 ", "
		ifvar "FilterFormat" "Any"
			regexpreplace ".*" "OK"
		endif

```

then in debug.out I get a double OK

```auto
Script-Line : 24
Command : ifvar
Parameter 1 : >FilterFormat<
Parameter 2 : >Any<

Output : ><

Line and position:
CD, Album, Reissue, Repress
^

------------------------------------------------------------

Script-Line : 25
Command : regexpreplace
Parameter 1 : >.*<
Parameter 2 : >OK<

Output : ><

Line and position:
OKOK
^

------------------------------------------------------------

```

Same thing happens with the regular expression `'.*$'`, whereas `'^.*'` and ` '.+'` give a single OK,  
Is this a bug or a feature of regular expressions?

---

<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: [October 17, 2023, 9:10am UTC](https://community.mp3tag.de/t/regexpreplace-ok-matches-twice/62436/2 "2023-10-17T09:10:46Z")

</div>

See here:

> [@\[X\] Replace with Regular Expression](https://community.mp3tag.de/t/x-replace-with-regular-expression/8140):
>
> Hi Florian, an example in German: Alt-5 Feld: NETRADIOSTATION Regulärer Ausdruck: ^.\*$ Treffer ersetzen durch: Jamendo Execution examples: Field is empty — Result: Field is still empty. Field is not empty — Result: Field's content = "Jamendo" IMHO this is a bug. Ciao, Andreas

---

<div class="post-metadata">

### Author: ![yorickausyps](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/f6c823/32.png) [@yorickausyps](https://community.mp3tag.de/u/yorickausyps)
#### Post date: [October 17, 2023, 9:20am UTC](https://community.mp3tag.de/t/regexpreplace-ok-matches-twice/62436/3 "2023-10-17T09:20:53Z")

</div>

So it seems to be a strange feature.  
Thank you for the answer.

---

<div class="post-metadata">

### Author: ![yorickausyps](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/y/f6c823/32.png) [@yorickausyps](https://community.mp3tag.de/u/yorickausyps)
#### Post date: [October 17, 2023, 3:32pm UTC](https://community.mp3tag.de/t/regexpreplace-ok-matches-twice/62436/4 "2023-10-17T15:32:05Z")

</div>

This seems to be the same Problem:

> [@replace with regular expression problem](https://community.mp3tag.de/t/replace-with-regular-expression-problem/3835):
>
> hi, I have a work-around for this, but I don't understand what the problem really is, and why I have solved it. Can anyone teach me? 1- What is being "falsely recognized" in the (.\*) case? 2- Why does [^] start of a line anchor solve the problem? Problem: title: 01 - Love's a Precious Thing One Strange Sunday using replace with regular expression field: title regular expression: (.\*) replace match with: junk $1 Produces: junk 01 - Love's a Precious Thing One St…

---

<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: [May 29, 2026, 12:37pm UTC](https://community.mp3tag.de/t/regexpreplace-ok-matches-twice/62436/5 "2026-05-29T12:37:06Z")

</div>

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