How to extract file name with regex

Hi,

I’m using a Text parser to extract file name on this URL : https://www.my-website.com/images/upload/cf_636eac991_my-wallpaper.jpg

I use this regex pattern ([^/]+$) but the output returned is https://www.my-website.com/images/upload/null instead of being cf_636eac991_my-wallpaper.jpg

I have tested many regex but unable to get the correct output.

Any idea?

Thanks
L.

This worked for me:

L

thank your for your feedback.

Seems to be not working, I get this on output => Imgur: The magic of the Internet

ouput should be only filename.

other point, do you know why on parser settings I have this setting Imgur: The magic of the Internet and not on your screen?

It seems you’re using the “Replace” version of the text parser but not giving a replacement value for matching text. That’s why you get null.

Either provide a replacement value for what you match or use the “Match pattern” version of the Text Parser.

L

1 Like

Welcome to the Make community!

To do this, you can use the built-in function replace — “Replaces the search string with the new string.”

{{ replace(text; search string; replacement string) }}

e.g.: (paste this into the field)

{{replace(filename; "/^[\w\W]+\//"; emptystring)}}

For more information, the function’s documentation can be found in the Help Centre. You should also complete the tutorials in the Make Academy.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

many thanks to both of you :slight_smile:

works with solution provided by @L_Duperval , I changed for “Match pattern” version of the Text Parser.

Many thanks again
L.

1 Like