#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)/assets(/[^\s/?&#]+)+"
Local $sString = "" & @CRLF & _
"-1" & @CRLF & _
"down vote" & @CRLF & _
"favorite" & @CRLF & _
"I need to search thru a sql file and find the filename (the end of the url) where the url contains /assets/" & @CRLF & _
"" & @CRLF & _
"Example url:" & @CRLF & _
"" & @CRLF & _
"https://www.example.com/assets/screenshots/this-is-an-example/2016-12-20_15-42-29.png" & @CRLF & _
"" & @CRLF & _
"It has /assets/ in it, so I want to get the last part of the url, being:" & @CRLF & _
"" & @CRLF & _
"2016-12-20_15-42-29.png" & @CRLF & _
"" & @CRLF & _
"Another example:" & @CRLF & _
"" & @CRLF & _
"https://www.example.com/images/screenshots/this-is-an-example/2016-12-20_15-42-29.png" & @CRLF & _
"" & @CRLF & _
"Nothing would return because /assets/ was not found." & @CRLF & _
"" & @CRLF & _
"*The number of directories deep it goes will be different, so it could be /assets/dir1/dir2/filename.jpg, and the next could be /assets/dir1/dir2/dir3/dir4/filename.jpg" & @CRLF & _
"" & @CRLF & _
"Hoping this can be accomplished using regular expression"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm