Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8184211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:25:35+00:00 2026-06-07T01:25:35+00:00

I am a network engineer with limited programming skills, I use a tool called

  • 0

I am a network engineer with limited programming skills, I use a tool called dnGREP that is based in NET4.0 for searching text within common text files. What I need to do as part of my job is finding commands applied to the configuration of any interface.

My idea is trying to find the correct REGEX limited by two items. But there are several issues that I am having while trying to build an efficient REGEX.

Taking the following string from a "show running-configuration" of a Cisco device:

interface GigabitEthernet0/0/0/1.1982
 ipv4 address 10.111.193.125 255.255.255.252
 ipv4 unreachables disable
 load-interval 30
 dot1q vlan 1982
!
interface GigabitEthernet0/0/0/1.1983
 ipv4 address 10.113.193.125 255.255.255.252
 ipv4 unreachables disable
 load-interval 30
 dot1q vlan 1983
!
interface GigabitEthernet0/0/0/2.1982
 ipv4 address 10.111.193.129 255.255.255.252
 ipv4 unreachables disable
 load-interval 30
 find me
 dot1q vlan 1982
 !    

As you can see, the interface configuration can be limited by 2 items.

Start Item:

    interface

End Item:

 !

Given a string I want a REGEX that matches the string along with the interface context.

Conditions:

  • The REGEX should return the interface context delimited by "interface" until "!".
  • The REGEX should print ALL the ocurrences

This is my REGEX so far:

 ^interface([\s\S]*?)find me([\s\S]*?)!

Breakdown:

^interface–"Start searching when "interface" is the beginning of the line."

([\s\S]*?—-"Search for any character including new line"

find me—-"find me is the string/command that I am looking for"

([\s\S]*?!—-"Keep printing until you find the !"

Of course above REGEX does not do what I expect. It should return this only:

interface GigabitEthernet0/0/0/2.1982
 ipv4 address 10.111.193.129 255.255.255.252
 ipv4 unreachables disable
 load-interval 30
 find me
 dot1q vlan 1982
 !  

Instead it returns all the stuff after the first interface is found which is not what I want.

I know why this is happening but I don’t know how to correct it.

"Regex starts searching for find me when the first interface is found however it should STOP if string find me is not found when reaching a ! declaring a no match HOWEVER it should continue until the end of the file and print all the interface contexts that contains the string find me"

I hope my explanation is clear. Any help is really appreciated =).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:25:37+00:00Added an answer on June 7, 2026 at 1:25 am

    Try the following regex:

    interface\s*(?<text>[^!]+find me[^!]+)(?:!)?
    

    Explanation:

    interface\s* – the word “interface” followed by 0 or more white spaces;

    (?<text>[^!]+find me[^!]+) – the group text containing any character except “!”, 1 or more repetitions and the string “find me”;

    (?:!)? – match the “!” character, but don’t capture it, 0 or 1 repetitions (to cater for the last paragraph, if the character is missing).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have several software packages (SolidWorks, Pro/ENGINEER, OrCAD, Minitab... ) that use FlexLM to
I'm programming a network multi-player game and I decided to use XMPP for communication
I develop a network based, multi-component software system that's designed to run on an
I have a dumb network device that has limited HTTP hosting capabilities and I'm
I was recently approached by a network-engineer, co-worker who would like to offload his
First off, I'm not a coder by profession, just a lowly network engineer :)
How to check that network is available or not on android device programmatically, which
I am 18 years old. I wish to become a network engineer. I don't
I have network application that handles about 40k msg/sec written using netty framework and
I am new to network programming, and have been learning this by writing small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.