Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-12-2019, 10:41 AM
jack_george jack_george is offline
Registered User
 
Join Date: Nov 2017
Posts: 12
Talking regular expression method to find specific word before specific index

i have index of specific word in paragraph and i need to get specific word and its index before this known index

i need to know if there is re method can help in this

paragraph: AP1 Fas 0/21 145 T B I AIR-CAP16 Gig 0.1 AP100 Fas 0/2 152 T B I AIR-CAP16 Gig 0.1 UNKOWN Fas 0/1 140 H P WSCC Port 1

Code:
word = "AIR-.*\w"

for ind,AP in enumerate(king):
    if re.search(word, AP):
        m = ind-5
        z.append(m)
        n = ind-6
        q.append(n)
    else:
        continue

for i in z:
    AP1.append(king[i])

for o in q:
    AP2.append(king[o])


for H in range (len(AP1)):
    fin.append(AP2[H] + AP1[H])

Last edited by jdev; 10-14-2019 at 10:57 AM. Reason: wrap code in [code][/code] blocks for easier viewing
Reply With Quote
  #2  
Old 10-14-2019, 11:08 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 941
jack_george,

It would be more appropriate to post such a question to a more python-specific support forum, whereas this scripting forum is specific to the context of SecureCRT's API and other automation specific to VanDyke Software products.

If resources become available in the future that will allow us looking into your regular expression inquiry, we'll be happy to help.

In the mean time, is there anyone in the forum community that can assist jack_george with his regular expression inquiry?
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
Reply

Tags
python


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:27 PM.