How to write a regular expression for return file name by trim its extensions,
Following are my files,
externals/tinymce/plugins/emotions/img/smiley-smile.gif
externals/tinymce/plugins/emotions/img/smiley-laughing.gif
externals/tinymce/plugins/emotions/img/smiley-wink.gif
externals/tinymce/plugins/emotions/img/smiley-tongue-out.gif
externals/tinymce/plugins/emotions/img/smiley-cry.gif
externals/tinymce/plugins/emotions/img/smiley-surprised.gif
externals/tinymce/plugins/emotions/img/smiley-embarassed.gif
I would like to get filename without its extension and trim its smiley from staring using regular expresion,
Expected Outputs,
smile, laughing, wink, tongue-out, cry, surprised, embarassed
You can use the regex:
.*smiley-(.*?)\.gif$
See it
The part you want will be in capture group 1.
You can use the following regex to match the text that you are interested in:
/smiley-([^.]+)\.[^.]+$/
The smiley name will then be present in capture group 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With