Community discussions

MikroTik App
 
User avatar
javajox
newbie
Topic Author
Posts: 44
Joined: Fri Aug 23, 2013 9:32 pm

String operations

Mon Dec 25, 2017 8:59 pm

Hello Guys!

I have strings like "something1%something2", I need to retrieve "something2". Example : let say I have this string "188.138.100.10%main_ether", I need a function that will retrieve the second part : "main_ether". How to do this using RouterOS built in scripting language. I can't find built in functions which can manipulate with strings :-(

Thank you
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: String operations  [SOLVED]

Mon Dec 25, 2017 9:27 pm

sure it is easy :wink:
{ 
:local str "something1%something2"; 
:put [:pick $str ([:find $str "%"]+1) ([:len $str])];   
} 
 
pekos
just joined
Posts: 1
Joined: Mon Mar 24, 2014 8:37 pm

Re: String operations

Thu Feb 21, 2019 4:11 am

Hi there

same question but how can someone get "something1" part? The scripting manual is hard to understand with :pick and :find. Can you please help?

Thanx

Who is online

Users browsing this forum: No registered users and 31 guests