I have one JPG that contains keywords like this example:
german1, german2, |, english1, english2
After
MyLanguageVerticalbarGermanIPTCKeywords => {
Require => 'IPTC:Keywords',
ValueConv => q{
$val = [ $val ] unless ref $val eq 'ARRAY';
my @newKeywords;
foreach (@$val) {
/^(.*?),? ?\|,? ?(.*?)$/ and push(@newKeywords,$1), last;
push(@newKeywords,$_);
}
return @newKeywords ? \@newKeywords : undef;
},
},
MyLanguageVerticalbarEnglishIPTCKeywords => {
Require => 'IPTC:Keywords',
ValueConv => q{
$val = [ $val ] unless ref $val eq 'ARRAY';
my @newKeywords;
foreach (@$val) {
/^(.*?),? ?\|,? ?(.*?)$/ and push(@newKeywords,$2), next;
push(@newKeywords,$_) if @newKeywords;
}
return @newKeywords ? \@newKeywords : undef;
},
},
I get two JPGs and the keyword part looks like this:
german1, german2,
, english1, english2
How can I delete the last comma after german2?
How can I delete the comma and the blank space before english1?
I have read:
\A
Matches only at the start of the string.
\Z
Matches only at the end of the string.
How can I realize this with ExifTool?
Thank you!
Which commas are keyword separators and which are part of the keywords themselves?:
german1, german2, |, english1, english2
- Phil
Thank you Phil for your reply!
, |,
comma...blank space...vertical bar...comma...blank space
Sorry, you lost me.
For example, I was looking for an answer something like this:
There are 3 keywords in my example:
1) "german1, german2"
2) "|"
3) "english1, english2"
- Phil
Hope this helps:
1) "german1, german2"
2) ", |, "
comma...blank space...vertical bar...comma...blank space
3) "english1, english2"
Great, thanks.
Try this:
MyLanguageVerticalbarGermanIPTCKeywords => {
Require => 'IPTC:Keywords',
ValueConv => q{
$val = [ $val ] unless ref $val eq 'ARRAY';
my @newKeywords;
foreach (@$val) {
/^(.*?),? ?\|,? ?(.*?)$/ and last;
push(@newKeywords,$_);
}
return @newKeywords ? \@newKeywords : undef;
},
},
MyLanguageVerticalbarEnglishIPTCKeywords => {
Require => 'IPTC:Keywords',
ValueConv => q{
$val = [ $val ] unless ref $val eq 'ARRAY';
my (@newKeywords, $found);
foreach (@$val) {
/^(.*?),? ?\|,? ?(.*?)$/ and $found = 1, next;
push(@newKeywords,$_) if $found;
}
return @newKeywords ? \@newKeywords : undef;
},
},
- Phil
That's it! Thank you very much Phil.