> [EMAIL PROTECTED] wrote:
>
> > Wizards (if there's any around this week),
> >
> > I've got a regexp I'm using to replace one SID in an HKEY_USERS registry
> > key with another, but I'm beginning to suspect there's something wrong
> > with it. It does work, but in fiddling with it, I discovered that it
> > still works when it shouldn't (I think). For example (output from a
> > test script),
> >
> > Old sid:
> > "Users/S-1-5-21-1294888362-425938668-1648912389-1005/Software/Microsoft/Internet
> > Explorer/Main//AutoSearch"
> > Now change the sid:
> > "Users/S-1-5-21-135449575-3924064129-568730901-1013/Software/Microsoft/Internet
> > Explorer/Main//AutoSearch"
> >
> > Well, that's the change I needed, but... Here's the original regexp:
> >
> > $line =~ s{[S\-0-9]{43,45}}{$new_sid};
> >
> > And, when I changed it to this:
> >
> > $line =~ s{S\-[0-9]{41,43}}{$new_sid};
> >
> > it still worked, and I think that should've failed--because '-' doesn't
> > match [0-9], right?
right.
> > That's when I began to suspect something was wrong.
i think your suspicions are very well founded and there's another problem.
i can't see any way your altered regex as given above can possibly work
as you describe. (the original regex should work.)
$bill's solution below should work just fine.
> > I don't know regexps well enough to be sure there's something wrong, or
> > to know how to write the regexp I *really want.*
first step: define what you really want. but then, you knew that!
>
> You need to include '-' in the char class:
>
> $line =~ s/S-[0-9-]{41,43}/$new_sid/;
best regards -- bill walters
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
