Skip to content
Advertisement

Tag: regex

Extract image src from a string

I’m trying to match all the images elements as strings, This is my regex: This works, but I want to extract the src of all the images. So when I execute the regular expression on this String: <img src=”http://static2.ccn.com/ccs/2013/02/img_example.jpg /> it returns: “http://static2.ccn.com/ccs/2013/02/img_example.jpg” Answer You need to use a capture group () to extract the urls, and if you’re wanting

JS Regex to find href of several a tags

I need a regex to find the contents of the hrefs from these a tags : Just the urls, not the href/ tags. I’m parsing a plain text ajax request here, so I need a regex. Answer You can try this regex: Example at: http://regexr.com?333d1 Update: or easier via non greedy method:

check if number string contains decimal?

After doing a sqrt() How can I be check to see if the result contains only whole numbers or not? I was thinking Regex to check for a decimal – if it contains a decimal, that means it didn’t root evenly into whole numbers. Which would be enough info for me. but this code isnt working… I bet there’s other

Regexp Matching Hex Color Syntax (and Shorten form)

Well, I’m pretty new on regex and in particular on JavaScript regexp. I’m looking for making a regexp that match the hex color syntax (like #34ffa6) Then I looked at the w3school page: Javascript RegExp Object Then that’s my regexp: It seems to work but, if I want it to match also the “short hex color syntax” form? (like #3fa),

Advertisement