A streaming language generally do not use command branching. However, SPL has plenty of instruments to obtain the result you want. So, let me rephrase your requirement. What I want is to extract from events is a vector of three components, field1, field2, field3. The method of extraction is based on whether the event contains dog or cat. To illustrate, given this dataset _raw a b c |i|j|k| Dog woofs l m n |x|y|z| Cat meows e f g |o|p|q| What does fox say? I want the following results _raw field1 field2 field3 a b c |i|j|k| Dog woofs a b c l m n |x|y|z| Cat meows x y z e f g |o|p|q| What does fox say? (This is based on reverse engineering your regex. As I do not know your real data, I have to make the format more rigid to make the illustration simpler.) Let me demonstrate a conventional method to achieve this in SPL. | rex "(?<field1_dog>\S+)\s(?<field2_dog>\S+)\s(?<field3_dog>\S+)\s"
| rex "\|(?<field1_cat>[^\|]+)\|(?<field2_cat>[^|]+)\|(?<field3_cat>[^|]+)\|"
| foreach field1 field2 field3
[eval <<FIELD>> = case(searchmatch("Dog"), <<FIELD>>_dog, searchmatch("Cat"), <<FIELD>>_cat)]
| fields - *_dog *_cat As you can see, the idea is to apply both regex's, then use case function to selectively populate the final vector. This idea can be implemented in many ways. Here is the emulation that generates my mock data. Play with it and compare with real data. | makeresults format=csv data="_raw
a b c |i|j|k| Dog woofs
l m n |x|y|z| Cat meows
e f g |o|p|q| What does fox say?" In many traditional languages, the requirement can also be expressed as conditional evaluation. While this is less conventional, you can also do this in SPL, usually with more cumbersome code.
... View more