Sep-01-2017, 03:22 PM
Greetings all,
I am parsing through lines in a file and what i am trying to do is look for any objects in position 5 (The line is getting split so it would be line[5]) and if line[5]contains an uppercase character anywhere in the name, I will then pass it to another portion of my script that will change the address to all lower case. So in the example below, line one would need to be changed
from: config firewall address trust edit "ADDRESS-216" set subnet 10.XX.181.163 255.255.255.255
to: config firewall address trust edit "address-216" set subnet 10.XX.181.163 255.255.255.255
below is a sample of the lines that are passed to the for loop:
config firewall address trust edit "ADDRESS-216" set subnet 10.XX.181.163 255.255.255.255
config firewall address trust edit "address-217" set subnet 10.XX.187.27 255.255.255.255
config firewall address trust edit "addRESS-218" set subnet 10.XX.69.163 255.255.255.255
config firewall address trust edit "ADDRess-219" set subnet 10.XX.75.27 255.255.255.255
config firewall address trust edit "ADDRESS" set subnet 10.XX.75.27 255.255.255.255
config firewall address trust edit "address" set subnet 10.XX.75.27 255.255.255.255
Below is a test where I have tried just using a list and doing a for loop to try to test changing the case with the following results. So I am not sure that isupper and isalpha work for my needs. But not sure how to get where I need to go.
ONE is good
two is good
Thr33 is good
four is good
FiVe368 is good
what I would want to see is
one
two is good
three
four is good
five368
I am parsing through lines in a file and what i am trying to do is look for any objects in position 5 (The line is getting split so it would be line[5]) and if line[5]contains an uppercase character anywhere in the name, I will then pass it to another portion of my script that will change the address to all lower case. So in the example below, line one would need to be changed
from: config firewall address trust edit "ADDRESS-216" set subnet 10.XX.181.163 255.255.255.255
to: config firewall address trust edit "address-216" set subnet 10.XX.181.163 255.255.255.255
below is a sample of the lines that are passed to the for loop:
config firewall address trust edit "ADDRESS-216" set subnet 10.XX.181.163 255.255.255.255
config firewall address trust edit "address-217" set subnet 10.XX.187.27 255.255.255.255
config firewall address trust edit "addRESS-218" set subnet 10.XX.69.163 255.255.255.255
config firewall address trust edit "ADDRess-219" set subnet 10.XX.75.27 255.255.255.255
config firewall address trust edit "ADDRESS" set subnet 10.XX.75.27 255.255.255.255
config firewall address trust edit "address" set subnet 10.XX.75.27 255.255.255.255
Below is a test where I have tried just using a list and doing a for loop to try to test changing the case with the following results. So I am not sure that isupper and isalpha work for my needs. But not sure how to get where I need to go.
listname = ['ONE', 'two', 'Thr33', 'four', 'FiVe368'] for test in listname: if test == test.isupper() and test.isalpha(): print(test.lower()) else: print(test + "is good")and the output I am getting is:
ONE is good
two is good
Thr33 is good
four is good
FiVe368 is good
what I would want to see is
one
two is good
three
four is good
five368