ruby on rails - Split between two characters -
i have url, being passed javascript. have @ moment
var link = '<%= @car.link.split('&')[1]%>'; link has id=63546&hjk i'm wanting have numbers passed ticket.
so 63546 left. how go this? has between these two. id= , &
thanks
does split needs done in rails side or in javascript side,. on both sides using regex string can splitted numbers
on ruby side
s ="id=63546&hjk" s[/\d+/].to_i => 63546 on javascript side
var regex = /\d+/g; var string = "id=63546&hjk"; var matches = string.match(regex); document.write(matches);
Comments
Post a Comment