I have a question about splitting string in javascript. I’m getting a string from somewhere else and I want to get only a part of it. I can’t use substr because its length can be altered. I also looked at split method, but it is not enough also. For example, one of my strings looks like this:
<img src="http://image.weather.com/web/common/wxicons/31/30.gif?12122006" alt="" />Partly Cloudy, and 84 ° F. For more details?
I only want to get img tag and the number 84. Any suggestion? Thanks
This is where one should use regular expressions.
You can do something like:
See a working example using this code:
http://jsfiddle.net/epkcn/