I'm not very experienced in Regex. Can you tell me how to get a string value from between two strings?
The subject will always be in this format : //subject/some_other_stuff
I need to get the string found between //
and /
.
For example:
Full String = //Manhattan/Project
Output = Manhattan
Any help will be very much appreciated.
You can use a negated character class and reference capturing group
#1
for your match result.Explanation:
You could use the below regex which uses lookarounds.
Since the strings are always of the same format, you can simply split them on
/
and then retrieve the element at index 2 (the third element):