Melba, you've missed the "at least" part before "4 capital letters". So make it {4,} <--- Oops, that was pretty dumb (eyes not fully open!) There is an issue: we still need to comply with the "last" requirement (last foldername). @OP, To make that work elegantly, may foldernames contain whitespaces? Are site name etc optional? If NO to both, try this: #include <Array.au3> ; For array display purpooses
$sStringData = "serverfolderfolderfolderfolderFOLDEr Site Name Etc" & @CRLF & _
"serverfolderfolderfolderFOLDerfolder Site Name Etc" & @CRLF & _
"serverfolderfolderfolderFOLDERfolder Site Name Etc" & @CRLF & _
"serverfolderfolderfolderfolderfolder SITE Name Etc" & @CRLF & _
"serverfolderfolderfolderfolderfolder WITH Site NAME Etc" & @CRLF & _
"serverfolderfolderfolderfolderfolder WITH Site NAME Etc" & @CRLF & _
"blah blah blah" & @CRLF & _
"serverfolderfolderfolderfolder2FOLDEr2 Site Name Etc"
$aRet = StringRegExp($sStringData, "(.*[[:upper:]]{4,}[^s]*)s[^]*", 3)
_ArrayDisplay($aRet)