How to get value betwwen to charachers in javascript

in this example we'll learn how to get a value inside a text, we need indexOf() and substring() to do this, let's go starter
<script>
var val = 'https://alitems.site/g/1e8d114494967748f8a616525dc3e8/?ulp=https://www.aliexpress.com/item/1005002805917234.html?algo_pvid=5567cd74-3097-470d-894c-e63ce496afc8&algo_exp_id=5567cd74-3097-470d-894c-e63ce496afc8-1&pdp_ext_f=%7B%22sku_id%22%3A%2212000022272277556%22%7D&pdp_pi=-1%3B148.95%3B-1%3B-1%40salePrice%3BUSD%3Bsearch-mainSearch';
var g1=val.indexOf("http")
var g2=val.indexOf(".html")
var g3=g2+5
var g4=val.substr(g3)
var g5=val.replace(g4,"")


document.write(g5) // https://alitems.site/g/1e8d114494967748f8a616525dc3e8/?ulp=https://www.aliexpress.com/item/1005002805917234.html




</script>
How to get value betwwen to charachers in javascript

© 2025 Manajmnt code

Share to :

Related

Comments

Post a Comment

message