my $input =q(C:\Windows\%Person%\%Class%); my @vars = $input =~ /%([^%]+)%/g;
local $, = $/; print @vars; On Tue, Apr 15, 2008 at 10:20 PM, Ley, Chung <[EMAIL PROTECTED]> wrote: > Hi, > > > > I have a program that will take in a string that will resolve to a path > where the output is going to store. > > > > The path can includes "variables" in this format "%<VariableName>%". > The acceptable variableNames that the program will support are fixed to > a list such as "Person", "Class", "Dept". This list may grow in the > future; but for now it is fixed. > > > > So, some of the acceptable strings are: > > C:\Windows\%Person%\%Class% > > C:\MyHomeDir\%Dept%\%Person% > > C:\MyHomeDir\%Dept%_%Person% > > and etc... > > > > I like to develop a validate method to return false when the string in > between the % pair don't belong to the acceptable list, and was trying > to do that with an expression. > > - Look for the string that is in between the "%" by the closest pair. > > - The "%" pair must start at the "odd" occurrence and finish on the > "next even" occurrence... Don't know how to describe this exactly, but > I don't want it to pack this up ("InBetween") from this > (C:\MyHomeDir\%Dept%InBetween%Person) even though it is in between a % > pair. > > - Then compare the string within the "%" pair to see if it belongs to > the "acceptable" list or not. > > > > Is using a regular expression the right approach here? or I should just > iterate thru? > > > > Thanks... > > > > --Chung Ley > >