[X] Regexp range repeat is broken


#1

In e.g. Convert | Tag - Filename

$regexp(aaa,a{2,4},X)

says

REGEXP ERROR: Regular expressionUnmatched { or{.wma

(sic) even though there is no unmatched { or {.

$regexp(aaa,a{2},X) works fine.


#2

comma breaks the syntax, it must be escaped
$regexp(aaa,'a{2,4}',X)


#3

it must be escaped

Oops! Thanks Dano.

Another addition needed to the list of reserved characters at help\main_scripting.html .

$regexp(aaa,'a{2,4}',X)

Actually I think that style is not in general safe, since it can break quoting already in the string. Safer is $regexp(aaa,a{2','4},X).

Also I find $regexp(aaa,(a{2,4}),X) is a workaround, possibly unintended!


#4

I recently found out (RegExpr für klassiche Beschriftung von Tonart) that the Mp3tag function $regexp(p1,p2,p3) expects as second parameter a literal string which contains the regular expression formular. Enclosing this literal string with single quotation characters allows the user to use any literal character in the regular expression, even those characters which needs compulsory to be escaped at other scripting places within Mp3tag.

I think it would become more clearly and handy if a user can read it from the documentation that parameter p2 of the Mp3tag scripting function $regexp(p1,p2,p3) should always be treated as a literal string which needs to be enclosed with single quotation marks.

By the way, round brackets should not to be allowed working as a string delimiter within function parameter list.

DD.20080304.2007.CET


#5

Enclosing this literal string with single quotation characters allows the user to use any
literal character in the regular expression, even those characters which needs
compulsory to be escaped at other scripting places within Mp3tag.

The exception being the quote character itself, mind! :wink:

round brackets should not to be allowed working as a string delimiter within function
parameter list.

It only appeared to, because the pattern parser took precedence over the function list parser. The proof is

$regexp(aaa,(a{2,4}),X$1Y) -> XaaaY

Given the docs, it's a bug.


#6

Hmm, yes, but from the sight within the regular expression the single quote character has to be escaped as ', or is this impossible, yet I didn't verify this situation?

DD.20080304.2203.CET

I played around a bit, now, I'm totally confused.

$regexp('a''aa','a',XY) gives XYXYXY

$regexp(a''aa,'a',XY) gives XY'XYXY

$regexp('a''aa','a''',XY) gives aaa

$regexp('a''aa','a'',XY) gives [ SYNTAX ERROR IN FORMATTING STRING ]

DD.20080304.2226.CET


#7

the single quote character has to be escaped as ',
or is this impossible, yet I didn't verify this situation?

No, it has to be escape by a quote i.e. to get one literal ' , you write '' .

I played around a bit, now, I'm totally confused.
$regexp('a''aa','a',XY) gives XYXYXY

A' went missing! I'm baffeld.

$regexp(a''aa,'a',XY) gives XY'XYXY

Figures.

$regexp('a''aa','a''',XY) gives aaa

Baffeld!

$regexp('a''aa','a'',XY) gives [ SYNTAX ERROR IN FORMATTING STRING ]

Figures.

By the way, Convert | Tag - Filename preview is a great way to try these fast.

DD.20080304.2226.CET
[/quote]


#8

'a''aa' is the same as aaa
if you want a'aa you must write 'a''''aa'


#9

I'm still unsure about escaping ...
$regexp('a''''aa','a''',x) which results in xaa.

DD.20080305.2024.CET


#10

There seems to be nothing wrong with this example.
Same as $regexp(baa,b,x) --> xaa


#11

... but ... analog to the b in your sample above ... a'''' is not the same as a'', obviously.

DD.20080306.0603.CET


#12

The escape function of the ' ends with the next ' (not like in e.g. delphi where the first and the last ' are connected.
So 'a''''aa'
is 'a' + '' + 'aa' whichis a + ' + aa


#13

So escaping in Mp3tag goes just the serial way from left to right, there is no 'recursively tree related view' to a string object.
This explains why a pure '' on a line displays not an empty string, but one '.
Thank you, Dano, to make this clear.
Is it true, that Mp3tag scripting language has no syntactical construct to represent an empty string?

DD.20080317.0914.CET