On Wednesday 22 August 2001 10:33 am, you wrote:
> Hello, I'm *BRAND NEW* to "the list" and have what may seem trivial to
> some of you - but (because of the pressure here at-the-office) I'd
> appreciate any help anyone could lend.
>
> I'm simply writing a program that will search one file for a string - if
> the string is found, replace it.
>
> What I'm running up against is: if the string that I'm looking in
> contains (1 or more) *'s, or +'s or .'s - I get an error.
>
> The line that I'm looking in is (almost) such as: $original_ip_address
> = deny+qfe1+tcp+*-*+0.0.0.0
> (can ya guess this is a firewall packet screen?)
>
> The syntax I'm using is:
>
> if ($looking_for =~ /$original_ip_address//) { $i += 1 }
> print "You Found A Match !\";
>
> However, the "$original_ip_address" is about 100 character line with
> multiple +'s, *'s, and .'s in it and I receive the error:
>
> nested *?+ in regexp at ...line #, etc...
>
> Lastly - I am (will be) prompting the user for input for an IP address
> to look for, but I know I'll run up against the variable containing .'s
> having problems. How (is there a way) to specify that a user input such
> as 123.111.222.111 can be assigned to be '123.111.222.111' (with the
> single quotes)
>
> As you can see, what my objective is - is to find the user's input (of
> an IP address) in a text file, and replace that IP address, (if found)
> with a new one. (They the user is too, prompted with.)
>
> I'm familiar enough with the s// syntax, but because of the dots, (.'s)
> in both the variables, I know I'll run up against problems.
>
> Any help?
>
> My appreciation for your time in advance - I know how valuable all of
> our time is.
>
> Bill
Have you tried escaping (i.e. placing a backslash \ in front of) the *'x +'s
and .'s
These are special characters used in RegEx, so if you are searching for any
of these they should be escaped.
--
Michael D. Risser
Software Engineer
Machine Vision Products, Inc.
www.visionpro.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]