Page 1 of 1

hdr.replaceAll('HDR10+','HDR10Plus') matches HDR10 as well

Posted: 28 Feb 2023, 17:32
by RLA
Not sure if this is a bug or my syntax error, but when I try to match 'HDR10+' with .replaceAll(), it matches HDR10 as well, which is not an accurate description of the file's format.

Code: Select all

hdr.replaceAll('HDR10+','HDR10Plus')
How do I get it to match only 'HDR10+' ?

Re: hdr.replaceAll('HDR10+','HDR10Plus') matches HDR10 as well

Posted: 01 Mar 2023, 00:00
by kim

Code: Select all

{ 'bla.bla.HDR10+.bla.bla'.replaceAll(/HDR10\+/,'HDR10Plus') }
output:
bla.bla.HDR10Plus.bla.bla

Re: hdr.replaceAll('HDR10+','HDR10Plus') matches HDR10 as well

Posted: 01 Mar 2023, 07:56
by rednoah
replaceAll takes a regular expression pattern, and HDR10+ happens to be a valid regex that matches HDR10 and HDR100 and HDR1000 and so on:
https://en.wikipedia.org/wiki/Regular_e ... c_concepts


:arrow: You can replace String values (as opposed to regular expression patterns) like so:

Code: Select all

{ hdr.replace('HDR10+':'HDR10Plus') }