Highlight RegExp

Here's the input line:

loadMedia('mediacontainer1', 'http://www.something.com/videos/JohnsAwesomeVideo.flv', 'http://www.something.com/videos/JohnsAwesomeCaption.xml', '/videos/video-splash-image.gif)

With this RegExp: \ '. +. xml \ '

... we get the following:

'mediacontainer1', 'http://www.something.com/videos/JohnsAwesomeVideo.flv', 'http://www.something.com/videos/JohnsAwesomeCaption.xml'

... but I want to extract only this:

http://www.something.com/videos/JohnsAwesomeCaption.xml

Any suggestions? I am sure this problem was asked before, but it is difficult to find. I will be happy to make a decision.

Thank!

+3
source share
4 answers

If you want to get everything in quotes that start with http:

(?<=')http:[^']+(?=')

If you need only those that end in .xml

(?<=')http:[^']+\.xml(?=')
  • It does not select quotes (as you requested)
  • This is fast!

Fair warning: it only works if your regular expression engine can handle lookbehind

+2
source

in.net this regex works for me:

\'[\w:/.]+\.xml\'

break it:

  • a 'character
  • ':' '/' '.' ( url)
  • ".xml" ( URL-, )

Edit , , , , , , . .net:

(?<=')[\w:/.]+\.xml(?=')

, , :

(?<=')[^']+\.xml(?=')

, .

+2

. , , + , , . , .

, , , .

perl. , , . +, , , [^.]+. Xml.

\'.+?.xml\'

, perl- .

+2

( javascript, , )

'[^']+?\.xml'

  • '
  • , '
  • .xml'

http://RegExr.com?2tp6q

+2

All Articles