Price, Jason (TLR Corp) wrote:
I'm trying to write a regular expression to divide up a line of text into a hash, but am having a hard time with it. I'm hoping you all can help me.
Here's an example line of text:
"( uiwgAttribute-OID NAME 'uiwgAttribute' DESC 'Contains meta data about an attribute' SUP top MUST cn MAY ( uiwgADsType $ uiwgDescription $ uiwgDisplayName $ uiwgIsMultiValued ) )"
Each line is similar, yet different. :) Basically, I want to divide
What is similar with each line? is every pair: capitol letters space value space
Here's somethign to play with and get you started, not 100% what your needs are...
#!/usr/bin/perl
use strict; use Data::Dumper;
my $string = q("( uiwgAttribute-OID NAME 'uiwgAttribute' DESC 'Contains meta data about an attribute' SUP top MUST cn MAY ( uiwgADsType $ uiwgDescription $ uiwgDisplayName $ uiwgIsMultiValued ) )");
my %passone = $string =~ m/\s?([A-Z]+)\s+\'([^']*)\'/g;
my %passtwo = $string =~ m/\s?([A-Z]+)\s+([^\s]*)/g;
my %values = (%passone,%passtwo);
print Dumper \%values;
HTH
Lee.M - JupiterHost.Net
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>