# A $regexp() irregularity

**URL:** https://community.mp3tag.de/t/a-regexp-irregularity/4504
**Category:** Export
**Created:** [February 22, 2007, 8:19pm UTC](https://community.mp3tag.de/t/a-regexp-irregularity/4504 "2007-02-22T20:19:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![umbeconomics](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/u/a88e57/32.png) [@umbeconomics](https://community.mp3tag.de/u/umbeconomics)
#### Post date: [February 22, 2007, 8:19pm UTC](https://community.mp3tag.de/t/a-regexp-irregularity/4504/1 "2007-02-22T20:19:16Z")

</div>

Briefly,

$regexp(1a-filename,'^[^ -]+([-])',$1) ~ $regexp(1a-filename,'^[^ -]+([-])',$strchr( -,$1)) ~ $regexp(1a-filename,'^[^ -]+([-])',$strchr( -,-))

emits

-filename ~ 0filename ~ 2filename

because

$regexp(1a-filename,'^[^ -]+([-])',$strchr( -$1,$1))

emits

3filename

The same is true of $strstr(). Several things puzzle me. Why wasn't the placeholder $1 expanded? Why don't I have to escape the dash, which is the RE special character used in ranges like [a-z], as - in a RE? For that matter, how is it that the RE escape character \ itself doesn't have to be escaped as \\ in a RE? That is,

$regexp(1a-filename,'^[^ -]+([-])',$strstr( -,))

emits

2filename

instead throwing an error for lack of a closing parenthesis.
