Link to home
Start Free TrialLog in
Avatar of sherbug1015
sherbug1015Flag for United States of America

asked on

Using RegEx to get a string

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.


User generated image
Avatar of arnold
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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