Kodi Community Forum

Full Version: Regex does not match square bracket
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone

In CreateSearchUrl I'd like to tread file names that contain an opening square bracket differently. However, I can't match the bracket in a regex.

The idea is to optionally put e.g. the director's name in the file name in square brackets.
The Pledge [Sean Penn].mp4
Angels Share.mp4

But it should not be used for the search, so I'd like to filter it in the expression of regex 1.
(If it matches, it 'calls' regex 2 which returns the matched string to the surrounding regex. If it doesn't, regex 3 will return the original string to the surrounding regex.)
However, I have problems with the special character. I have the impression that the square bracket is being replaced before it's passed to the regex.
I tried the noclean option but without effect. I guess that applies to the special charaters in the output.
Do you have any idea? Thanks.

<CreateSearchUrl dest="3">
    <RegExp input="$$6" output="&lt;url&gt;http://test.com/q=\1&lt;/url&gt;" dest="3">
        <RegExp input="$$1" output="\1" dest="7"><!-- regex 1 -->
            <expression clear="yes" noclean="1">(.+)\[.*</expression>
        <RegExp input="$$7" output="\1" dest="6"><!-- regex 2 -->
        <RegExp input="$$7" output="$$1" dest="6"><!-- regex 3 -->
        <expression noclean="1" />