Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: .VCF records cleansing

by hippo (Chancellor)
on Apr 08, 2020 at 10:21 UTC ( #11115216=note: print w/replies, xml ) Need Help??


in reply to .VCF records cleansing

Hello, solocazzimiei and welcome to the Monastery. It is quite difficult to read your code in this post and it would help considerably if you could enclose each section of code within <code>...</code> tags.

While it is not entirely clear what you actually want here, you can use many techniques to separate a key from a value based upon the first colon. Since you are using a regex anyway, here is one such.

use strict; use warnings; use Test::More tests => 2; my $in = "NOTE;ENCODING=QUOTED-PRINTABLE:=0AAddress:=0A=0Aor. Soroca=0 +ARepublic of Moldova=0A=0A=0A=0A Footwear. =Children's footwear. Lady +'s footwear."; my $want_key = 'NOTE;ENCODING=QUOTED-PRINTABLE'; my $want_value = "=0AAddress:=0A=0Aor. Soroca=0ARepublic of Moldova=0A +=0A=0A=0A Footwear. =Children's footwear. Lady's footwear."; $in =~ /^([^:]+):(.*)/; is $1, $want_key, 'Key matches'; is $2, $want_value, 'Value matches';

Equally, you could use split or even index and substr to achieve the same end.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11115216]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2021-06-18 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (87 votes). Check out past polls.

    Notices?