Using RegEx to get a string

sherbug1015 used Ask the Experts™
Please see attached image.  On the first line, I need to extract everything between the two / /

Which means the / after getfile and the / after the guid.  I just want to end up with the first guid

Can someone help me with some RegEx to do that.  I have been asked not to use substring.


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017
The guid will be in $1 the match variable.

The matched variable might differ with different languages.
Most Valuable Expert 2017
Distinguished Expert 2018

Further to arnold's post here is some javascript that will do it for you. The pattern is slightly different it does a non-greedy match of everything after the second '/' to the third '/'
var pattern = /\/cms\/getfile\/(.*?)\//;

$(function() {
  $('button').click(function() {
    var input = $('#url').val();
    var result = input.match(pattern);

Open in new window

Working sample here

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial