Thread Ersetzen Character ab definierten Positionen innerhalb eines Strings ( Single/Double Quotes)
(2 answers)
Opened by bora99 at 2021-03-24 20:47 2021-03-24T19:47:54 bora99 Wenn ich es richtig verstehe, könnte es ungefähr so gehen: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #!/usr/bin/perl use strict; use warnings; my @strings = ( "'VAL1','VAL2',\"VALX\"" , "foo 'VAL1','VAL2',\"VALX\"" , "foo 'VAL1','VAL2',\"VALX\" bar" , "'VAL1','VAL2',\"VALX\" bar" ); for my $string (@strings) { my ($prefix, $innerstring, $postfix) = $string =~ /(.*?["'])(.+)(["'].*)/; $innerstring =~ s/["']//g; print $prefix, $innerstring, $postfix, "\n"; } HTH Grüße payx Last edited: 2021-03-25 08:28:59 +0100 (CET) |