Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

splitting regex

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
HI,
Having a line like :

NodeList"="YCS1470-685;YCS1472-685;YCS1471-685;YCS1473-685"

Need to split it into an array containing:

YCS1470-685 YCS1472-685 YCS1471-685 YCS1473-685

The line may contain more then 4 values.
Thanks in advance

Long live king Moshiach !
 
Code:
#!/usr/bin/perl

use strict;

my $node_str="YCS1470-685;YCS1472-685;YCS1471-685;YCS1473-685";
my @node_ary = split( /\;/, $node_str );

for (@node_ary) {        
    print $_ . "\n";
}

M. Brooks
 
Thanks,

but the full string is:

my $node_str = NodeList"="YCS1470-685;YCS1472-685;YCS1471-685;YCS1473-685"


Long live king Moshiach !
 
actualy:

my $node_str = \"NodeList\"=\"YCS1470-685;YCS1472-685;YCS1471-685;YCS1473-685\""


Long live king Moshiach !
 
Before I go any further I must ask, what generated the string below?

NodeList"="YCS1470-685;YCS1472-685;YCS1471-685;YCS1473-685"

Is this from CGI parameter input? Output from a file? Just curious.

M. Brooks
 
Code:
$node_str =~ s/"//g; # remove quotes
my (@node_ary) = split (/\;/, (split(/=/, $node_str))[1]);

-------------
Cuvou.com | The NEW Kirsle.net
 
Another way:
Code:
my $node_str = 'NodeList"="YCS1470-685;YCS1472-685;YCS1471-685;YCS1473-685"';
$node_str =~ m/="([^"]+)"/;
my @a = split ';', $1;
 
Thanks to all. Mbrooks this is a result of "registry -e" command on Windows,just dumping registry.
Thanks

Long live king Moshiach !
 
Status
Not open for further replies.

Similar threads

Replies
2
Views
347
  • Locked
  • Question Question
Replies
4
Views
468
  • Locked
  • Question Question
Replies
1
Views
305
  • Locked
  • Question Question
Replies
5
Views
447

Part and Inventory Search

Sponsor

Back
Top