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

Any questions? Need some help?
Post Reply
RLA
Posts: 3
Joined: 26 Jul 2021, 15:55

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

Post 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+' ?
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

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

Post by kim »

Code: Select all

{ 'bla.bla.HDR10+.bla.bla'.replaceAll(/HDR10\+/,'HDR10Plus') }
output:
bla.bla.HDR10Plus.bla.bla
User avatar
rednoah
The Source
Posts: 23073
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post 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') }
:idea: Please read the FAQ and How to Request Help.
Post Reply