Fitgo Posted April 19, 2014 Share Posted April 19, 2014 I would like to find a way to give back all the way before: Application With: C:Program Files (x86)GoogleChromeApplicationApplicationApplicationApplicationApplicationApplication33.0.1750.154Installersetup.exe Return: C:Program Files (x86)GoogleChromeApplicationApplicationApplicationApplicationApplicationApplication With: C:Program Files (x86)GoogleChromeApplication33.0.1750.154Installersetup.exe Return: C:Program Files (x86)GoogleChromeApplication Use StringRegExp. Thanks for help. Link to comment Share on other sites More sharing options...
Fitgo Posted April 19, 2014 Author Share Posted April 19, 2014 (?U)[[:alpha:]]:\\ then I do not know how to continue Link to comment Share on other sites More sharing options...
jguinch Posted April 19, 2014 Share Posted April 19, 2014 $sString = "C:\Program Files (x86)\Google\Chrome\Application\Application\Application\Application\Application\Application\33.0.1750.154\Installer\setup.exe" $sResult = StringRegExpReplace($sString, "(.*Application\\).*", "$1") ConsoleWrite($sResult & @CRLF) $sString = "C:\Program Files (x86)\Google\Chrome\Application\33.0.1750.154\Installer\setup.exe" $sResult = StringRegExpReplace($sString, "(.*Application\\).*", "$1") ConsoleWrite($sResult & @CRLF) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
jchd Posted April 19, 2014 Share Posted April 19, 2014 Like this? Local $path = "C:\Program Files (x86)\Google\Chrome\Application\Application\whatever else...\Application\Application\Application\Application\33.0.1750.154\Installer\setup.exe" Local $root = StringRegExpReplace($path, "(.*\\Application\\)(.*)", "$1") ConsoleWrite($root & @LF) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
jguinch Posted April 19, 2014 Share Posted April 19, 2014 (edited) Well, I forget the "" before Application...Fortunately, JC has been there Can also be $sResult = StringRegExpReplace($sString, "(?i)(.*Application).*", "$1") Edited April 19, 2014 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Fitgo Posted April 19, 2014 Author Share Posted April 19, 2014 Thanks to both of you. I solved with the solution of jchd. However, if I want to take only the letter of the partition on? Example: $%&''C:Program Files (x86)GoogleChromeApplicationApplicationwhatever else...ApplicationApplicationApplicationApplication33.0.1750.154Installersetup.exe Return: C:Program Files (x86)GoogleChromeApplicationApplicationwhatever else...ApplicationApplicationApplicationApplication Should I implement something like this: (?U)[[:alpha:]] How do I? Thanks for help. Link to comment Share on other sites More sharing options...
jguinch Posted April 19, 2014 Share Posted April 19, 2014 (edited) Yes, something like $sLetter = StringRegExpReplace($sString, "(?i).*([[:alpha:]]):.*", "$1"), or just $sLetter = StringRegExpReplace($sString, "(?i).*([A-Z]):.*", "$1") Edited April 19, 2014 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
jchd Posted April 19, 2014 Share Posted April 19, 2014 Local $path = "$%&'a:(not there!)@'C:\Program Files (x86)\Google\Chrome\Application\Application\whatever else...\Application\Application\Application\Application\33.0.1750.154\Installer\setup.exe" Local $root = StringRegExpReplace($path, "(?i).*((?<![a-z])[a-z]:(?=\\).*\\Application\\)(.*)", "$1") ConsoleWrite($root & @LF) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
mikell Posted April 19, 2014 Share Posted April 19, 2014 (edited) jc, isn't this good enough ? Local $root = StringRegExpReplace($path, "(?i).*([a-z]:\\.*\\Application\\).*", "$1") (because of the greediness of the first .* ) Edited April 19, 2014 by mikell Link to comment Share on other sites More sharing options...
jchd Posted April 19, 2014 Share Posted April 19, 2014 (edited) I was protecting against this case (unlikely in the samples shown but more robust in the general case): Local $path = "$%&'a:(not there!)@'C:\Application\33.0.1750.154\Installer\setup.exe" Local $root = StringRegExpReplace($path, "(?i).*([a-z]:\\.*\\Application\\).*", "$1") ConsoleWrite($root & @LF) Edited April 19, 2014 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
mikell Posted April 19, 2014 Share Posted April 19, 2014 (edited) OK this makes the lookahead clear, but what about the lookbehind ? StringRegExpReplace($path, "(?i).*([a-z]:(?=\\).*\\Application\\).*", "$1") Edited April 19, 2014 by mikell Link to comment Share on other sites More sharing options...
jchd Posted April 19, 2014 Share Posted April 19, 2014 (edited) Yes, as well. And like I just told jguinch in PM, it was what I came up with while watching my movie and monitoring the cooking of my home-made pizza. Cat & skins, as usual. Edited April 19, 2014 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Fitgo Posted April 19, 2014 Author Share Posted April 19, 2014 Local $path = "$%&'a:(not there!)@'C:\Program Files (x86)\Google\Chrome\Application\Application\whatever else...\Application\Application\Application\Application\33.0.1750.154\Installer\setup.exe" Local $root = StringRegExpReplace($path, "(?i).*((?<![a-z])[a-z]:(?=\\).*\\Application\\)(.*)", "$1") ConsoleWrite($root & @LF) Very thanks. I have solved. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now