Skip to main content
Question

How to match only first occurence with regex?

  • February 8, 2024
  • 3 replies
  • 59 views

Forum|alt.badge.img+4
  • Steward **
  • 27 replies

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

fgbetokpanou
Centreonian
Forum|alt.badge.img+11
  • Centreonian
  • 189 replies
  • February 12, 2024

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

 

Cheers, 


Forum|alt.badge.img+4
  • Author
  • Steward **
  • 27 replies
  • February 12, 2024

I got the solution. Thanks

 


fgbetokpanou
Centreonian
Forum|alt.badge.img+11
  • Centreonian
  • 189 replies
  • February 12, 2024

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