Community discussions

 
tuncerinan
just joined
Topic Author
Posts: 9
Joined: Mon May 21, 2018 10:26 am

Parse issue

Wed Sep 19, 2018 4:30 pm

Hi Dear,

How ı parse this value ether1:cc|ether2:xx|ether9:zz| .I wanna parse between | .


Result:
ether1:cc
ether2:xx
ether9:zz



Thanks.
 
User avatar
rendezz
just joined
Posts: 15
Joined: Mon Sep 17, 2018 11:07 am

Re: Parse issue

Fri Sep 21, 2018 9:51 am

Try this
:local test "ether1:cc|ether2:xx|ether9:zz|"
:local found 0

:while ([:len ($test)] > 0) do={
	:set found [:find $test "|" -1]
	:if ($found = "") do={
	     :put $test
	     :set test ""
	} else={
	     :put [:pick $test 0 $found]
	     :set test [:pick $test ($found+1) [:len ($test)]]
	}
}
Home of the Badjr, the cloud-managed business network router built on Mikrotik http://baselinecloud.com/badjr

Who is online

Users browsing this forum: No registered users and 13 guests