Is there any way to fetch last three alphabets between two slashes from a string using regular expression

Viewed 34

From the string

t/123test/abc/qwe/jul/374634

I need to fetch test and store it in a variable.

Need to fetch the strings between slashes and store it in different variables.

Have tried using ^\.t\/.*[A-Z]{3}.*\/\w{3} but its not getting populated correctly.

Could you please advise on the same.

1 Answers

You may use

^t/\d*([a-zA-Z]+)

See the regex demo and the regex graph:

enter image description here

Details

  • ^ - start of string
  • t/ - t/ substring
  • \d* - 0+ digits
  • ([a-zA-Z]+) - Group 1: any one or more ASCII letters.
Related