DW1 Posted May 5, 2009 Share Posted May 5, 2009 Hi guys, it's been a while since I have posted Work is keeping me too damn busy lol.I need help getting a regular expression to work properly.I have a file which contains data like:Status : lable::somefunc() : "C:\Program Files\Common Files\something shared" Status : lable2::otherfunc() : "string here", "C:\Program Files\Common Files\something shared" SomeLable::datalogging::func(var) : : Object did some thing C:\Program Files\Common Files\something shared\somedll.dll on thread 0x0000000A.I need to strip the file path out. They are not all going to be on the C: drive.The return I would be looking for would look like this:Status : lable::somefunc() : "something shared" Status : lable2::otherfunc() : "string here", "something shared" SomeLable::datalogging::func(var) : : Object did some thing somedll.dll on thread 0x0000000A.Note that I will still need the last entry from the path. If it is a file, then I need to keep the file name, and if it is a directory, I need to keep the lowest directory name.I would need to loose everything between the 'X:\' the last '/' for every path.Thanks a lot guys AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 5, 2009 Share Posted May 5, 2009 $str = 'Status : lable::somefunc() : "C:\Program Files\Common Files\something shared"' & @CRLF & _ 'Status : lable2::otherfunc() : "string here", "C:\Program Files\Common Files\something shared"' & @CRLF & _ 'SomeLable::datalogging::func(var) : : Object did some thing C:\Program Files\Common Files\something shared\somedll.dll on thread 0x0000000A.' ConsoleWrite(StringRegExpReplace($str, '\w{1}:\\[a-zA-Z \\]+\\', '') & @CRLF) Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
DW1 Posted May 5, 2009 Author Share Posted May 5, 2009 Thanks Mega Can you break that down for a noob? I am writing this for a console app that just does regex (project requirement) and that regex killed it haha. Probably just a difference in engines, so I need assistance breaking down the logic. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 5, 2009 Share Posted May 5, 2009 Hi, \w*:\\[a-zA-Z \\]+\\ \w* means drive letter which is optional (*) because could be \\...\...\ as a path : \\ means \ [a-zA-Z \\] all the signs which are possible in the path. You may add äöü or something. \\ end with a \ Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
DW1 Posted May 5, 2009 Author Share Posted May 5, 2009 Thanks so much Mega, what about the "+" if I remove the "+\\" it will not crash the app, but will not be correct results because I modified it. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Xenobiologist Posted May 5, 2009 Share Posted May 5, 2009 Hi,what crashed what? Have a look at : http://www.autoitscript.com/autoit3/pcrepattern.htmlMega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
DW1 Posted May 5, 2009 Author Share Posted May 5, 2009 Thanks Mega, I will be talking with the person who wrote our regex engine. I think there may be something wrong with it. Your solution is elegant and works flawlessly. It is our engine that needs help. You rock! Regards, DW AutoIt3 Online Help 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