Ad Widget

Collapse

Regex trigger on string of text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JD2000
    Junior Member
    • Aug 2013
    • 3

    #1

    Regex trigger on string of text

    I'm having a problem getting a trigger using regex working as intended.
    I have an ssh command that returns a string like so:
    OK OK OK OK OK OK
    or
    ERROR OK OK OK OK OK

    I'm trying to setup 6 separate triggers for each word in the sting. For instance, if the first item reads anything other than "OK" then the trigger should be thrown. Same for the 2nd - 6th results. They will always be singe words separated by a space.

    I'm using global regular expressions and this is what I have so far to evaluate the first item:
    global regex: ^(OK)(\s\w*){6}
    named: test1Service

    And the following trigger:
    (({eRad Template:ssh.run[services].regexp(@test1Service)})#1)

    and for my second item:
    global regex: ^(\w*\s)(OK)(\s\w*){4}
    named: test2Service

    And the following trigger:
    (({eRad Template:ssh.run[services].regexp(@test2Service)})#1)

    But neither are working correctly. Is there a better way to do what I'm trying to accomplish?
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    One alternative could be:
    .regexp("^(\[^ \]+ ){0}ERROR")
    .regexp("^(\[^ \]+ ){1}ERROR")
    .regexp("^(\[^ \]+ ){2}ERROR")
    ...

    Comment

    Working...