Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: Extract delimited words from string

by atcroft (Abbot)
on Dec 09, 2022 at 00:36 UTC ( [id://11148676]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Extract delimited words from string
in thread Extract delimited words from string

Simple enough-the extract_multiple() function can apply multiple functions or regular expressions to do so. Changing the extract_multiple() line to the following:
@extracted = extract_multiple( $str, [ \&extract_quotelike, qr/\s+/, ], );
results in the following output:

Input: 50 0 "R0 G255 B0 A255" "Solid" 118 1 "R0 G0 B0 A255" "R0 G0 B0 + A255" 0 Output: 50 0 "R0 G255 B0 A255" "Solid" 118 1 "R0 G0 B0 A255" "R0 G0 B0 A255" 0 Input: 70 0 "R0 G255 B255 A255" "Solid" 118 1 "R12 G12 B12 A255" "R12 + G12 B12 A255" 0 Output: 70 0 "R0 G255 B255 A255" "Solid" 118 1 "R12 G12 B12 A255" "R12 G12 B12 A255" 0

(My original code was just extracting based on the quotation marks as delimiters.)

Hope that helps.

Replies are listed 'Best First'.
Re^6: Extract delimited words from string
by LanX (Saint) on Dec 09, 2022 at 02:24 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-25 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found