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.

Thanks.

docid.jpg
sherbug1015Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
m/\/cms\/getfile\/([0-9a-fA-F\-]+)\//
The guid will be in $1 the match variable.

The matched variable might differ with different languages.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
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 '/'
<script>
var pattern = /\/cms\/getfile\/(.*?)\//;

$(function() {
  $('#pattern').html(pattern);
  $('button').click(function() {
    var input = $('#url').val();
    var result = input.match(pattern);
    $('#resultbox').html(result[1]);
  });
});
</script>

Open in new window


Working sample here
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.