-1

I am trying to get the filename with an extension from the absolute path using regex for e.g.:-
./app/txt.graphql ./txt.graphql ./test/app/bin/txt.graphql

I wanna just get the full filename with an extension like- txt.graphql from the above path using regex

Andy Lester
  • 91,102
  • 13
  • 100
  • 152

1 Answers1

-1

It sounds like you're asking for "all the non-slash characters after a slash".

So you want this:

/([^/]+)$

and then you use the capture group.

The first slash is just a literal slash. [^/] means "non-slash character". + means "one or more". $ means "end of the string. And () wraps up the capture group.

I can't tell you how to get the capture group because you haven't said what tool or language you're using.

Andy Lester
  • 91,102
  • 13
  • 100
  • 152