Jump to content

StringRegExp Help


 Share

Recommended Posts

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

$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)

Link to comment
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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

Well, I forget the "" before Application...Fortunately, JC has been there

Can also be $sResult = StringRegExpReplace($sString, "(?i)(.*Application).*", "$1")

Edited by jguinch
Link to comment
Share on other sites

Thanks to both of you. :) I solved with the solution of jchd. :D

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

Yes, something like

$sLetter = StringRegExpReplace($sString, "(?i).*([[:alpha:]]):.*", "$1"),

or just $sLetter = StringRegExpReplace($sString, "(?i).*([A-Z]):.*", "$1")

Edited by jguinch
Link to comment
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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

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 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 here
RegExp tutorial: enough to get started
PCRE 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

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 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 here
RegExp tutorial: enough to get started
PCRE 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

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...