Question

How to match only first occurence with regex?

  • 8 February 2024
  • 3 replies
  • 41 views

Badge +4

I get as ouput for an interface this:

“Interface '1' Status : up (admin: up), Traffic In : 28.37Kb/s (0.00%), Traffic Out : 215.18Kb/s (0.02%)

Interface '1' Status : down (admin: up)”

 

My regex is this ‘^1$’. But I want to match it for the first occurence only so that I get the right output. 

Thank you for your help


3 replies

Userlevel 5
Badge +11

Hi @query, have you taken the time to have a look at these two articles?
 

 

Cheers, 

Badge +4

I got the solution. Thanks

 

Userlevel 5
Badge +11

I got the solution. Thanks

 

Good! Please feel free to share the solution with the community. Then someone else who is experiencing the same problem might be able to use it as well. Thank you very much in advance  

Reply