afrojojo Posted October 18, 2011 Share Posted October 18, 2011 Hello masters of the regex. I would like your help. I need an expression that would extract the version out of this string. Everything between the last "-" and ".". INPUT: database_name-10182011946-v1.0.2.sql OUTPUT: v1.0.2 Any ideas? Link to comment https://forums.phpfreaks.com/topic/249326-searching-for-a-string/ Share on other sites More sharing options...
joe92 Posted October 18, 2011 Share Posted October 18, 2011 Will every file end as .sql? And will every version number start as v? If so something like: /(v\d\.\d\.\d)(?=\.sql)/ The \d stands for any digit between 0 and 9. The second set of brackets is to make sure it ends with .sql. Link to comment https://forums.phpfreaks.com/topic/249326-searching-for-a-string/#findComment-1280234 Share on other sites More sharing options...
afrojojo Posted October 18, 2011 Author Share Posted October 18, 2011 Awesome! Thanks. Link to comment https://forums.phpfreaks.com/topic/249326-searching-for-a-string/#findComment-1280239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.