Jump to content

RegEx help please :)


Recommended Posts

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 ^_^

Link to comment
Share on other sites

$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

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.

Link to comment
Share on other sites

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

Hi,

what crashed what?

Have a look at : http://www.autoitscript.com/autoit3/pcrepattern.html

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...