Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Regex Optimization Question

by Roy Johnson (Monsignor)
on Mar 23, 2006 at 18:57 UTC ( [id://538828]=note: print w/replies, xml ) Need Help??


in reply to Regex Optimization Question

This seems to do basically what you want. I just extract what's between quotes and join them together with a backslash. Updated to handle "Account Deleted".
use strict; use warnings; my $string = q/ Win32_Account.Domain="ADDomain",Name="aduser1"/; for my $string (q/ Win32_Account.Domain="ADDomain",Name="aduser1"/, q/ Win32_Account.Domain="ADDomain",Name=""/) { my @fields = $string =~ /"(.*?)"/g; printf "New string is (%s)\n", $fields[1] eq '' ? 'Account deleted' +: join '\\', @fields; }

Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-03-29 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found