Em Ae
Em Ae

Reputation: 8704

Need help for a regular expression

I have following sample string

test1/test2/test3:test4/test5/test6IAmInterestedIn:test7/test8

I am only interested in test6IAmInterestedIn which is after fourth slash and can consist of 3 characters, multiple letters and end with 3 digits i.e. [A-Z]{3}[0-9]{3}.

What I want to add to the above regular expression, that I always pick up the string after the fourth slash which matches [A-Z]{3}[0-9]{3}. How can i do so ?

Upvotes: 1

Views: 50

Answers (1)

ergonaut
ergonaut

Reputation: 7057

You can try this DEMO

(?:[^\/]*\/){4}([A-Za-z]{3}[0-9]{3})

where

  • (?:[^\/]*\/){4} matches 4 blocks that contain forward slash
  • ([A-Za-z]{3}[0-9]{3}) captures your desired pattern

Upvotes: 1

Related Questions