Parse IP Address

I am trying to get the third octet in the client IP Address that will designate the zone the client resides in. So far I haven’t been able to create an expression tag to perform that function.




split() will create a dataset, with each row being equal to the values between the separator string. The \. is a regex, for a period. Finally, [2,0] is the row,column of the 3rd octet.

Thank you for the fast reply.

I copied and pasted:
toInt(split(“source text string”,"\.")[2,0])
into the expression of my expression tag and get an “Evaluation Error”.

Did you replace the source text for an actual IP address?

You can wrap it in a try in case there is an invalid address, syntatically speaking

try(toInt(split("source text string","\\.")[2,0]),-1)







To expand on Kyle’s solution, to use the client’s IP address:


EDIT: Added “try” function

I’m using the system variable

This is inside an Expression Tag

I’m running 7.7.1 rc2

Ah. Try putting it in a Client Tag.

EDIT: You’ll really want to put it in a Client Tag anyway, because you want it to work just inside each client. Expression Tags are global in nature.

What Jordan said is correct. That tag is not available in the gateway, as it is unique to the client runtime.

Thank you, that did it!

I was testing on the wrong one, I had a client tag I was experimenting with as well but was attempting your suggestion with an expression tag.