Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Javascript Substr equivalent

$
0
0

Hi,

 

I would like to extract a portion of a string:

 

JS: "Hello world A \n Hello Universe B \n Hello Earth C\n"

AutoIt: "Hello world A {@CRLF} Hello Universe B {@CRLF} Hello Earth C {@CRLF}"

 

If i pass "Universe" to the function, I would like to get "B".

 

Javascript Code:

 

var str="Hello world A \n Hello Universe B \n Hello Earth C\n";
var param="Universe"
var pos = str.indexOf(param) +param.length ;
var n= str.substr(pos);
pos = n.indexOf("\n");
n = n.substr(0,pos);
 

<<n would return B>>

 

AutoIt code:

$str="Hello world A {@CRLF} Hello Universe B {@CRLF} Hello Earth C {@CRLF}" $param="Universe" $pos= StringInStr ($str, $param) + StringLen($param) ;todo $pos2 = StringInStr($str, @CRLF) ;todo

What would be a good equivalent here?

 

Thank You!

 

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>