RegEx

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

RegEx

Post by PepsiHog » Sun May 18, 2014 2:56 am

@Marcus,

The new forum looks nice. Thanks.

@Everyone,

At this point I've been working with RegEx for some time. I'm starting to feel more confident with what I can accomplish using RegEx. However, I need a little help with this one.

BASICS: I have three strings that get populated with numbers. Numbers 1 thru 52. The strings are populated for different reasons. I have been trying to use LookAhead to find any numbers that repeat 3x.

I have had some success at this, but it seems if there are more repeats or less repeats the result is not what I am looking for.

Here is the practice code I've been working on.

Code: Select all

let>String1=10;20;30;40;50;
let>String2=5;15;25;30;45;50;
let>String3=2;4;8;15;30;50;

RegEx>(.*)\b(.*)(\d\d?)(?=.*\b\1\b)(?=.*\b\2\b);,%String1%%String2%%String3%,0,MatchA,NomA,1,$1,Test

RegEx>(.*)\b(\d\d?)(?=.*\b\1\b);,Test,0,MatchB,NomB,1,$1,Last

mdl>%Test%  /  %Last%    (%MatchB_1%  /  %MatchB_2%  /  %MatchB_3%  /  %MatchB_4%)
Oh, yeah. Just to make my life more difficult, I have been trying to get the results in the replace result(Test, in this case.)
I could just use a loop to get all the matches, I suppose. But I like to make things complicated.

I'm not worried about the result being in the replace string so much, as just finding all repeats that repeat 3 times, consistently.

Don't be confused by my scrap code above. I am asking, "How can I find all repeats that repeat 3 times." Everything else is just me being complicated. However, if placing the results in the replace string is possible, with it working consistently I'd really like it to do that.

If you play with what I have and change the numbers to make more or less repeats, you should see how the result doesn't reflect all repeats.

Thanks in Advance,
PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: RegEx

Post by PepsiHog » Wed May 28, 2014 4:05 pm

:lol: By now I thought I'd have a reply. Strange.

Any who. Doesn't matter. I figured it out, and now I'd like to share what I learned.

The answer was to use a Negative LookAhead. Instead of looking for what I needed, I looked for what I didn't need. Since LookAhead consumes the results the only thing left is what I wanted.

Plus I simplified. I compared the first two strings. Then compared the third string with the results of the first RegEx. This removed any result that didn't again repeat. Making the result be of numbers that repeated in the first and second search.(Repeated 3 times.)

Doing it this way made it easy to place the results in the Result String of RegEx.

@Marcus,

Just curious. By mistake I left out the Replace String in my RegEx, which should have been $1. But it worked the same without it. The Replace Result was still correct.

My mistake was >RegEx>\b(\d\d?)\b(?!.*\b\1\b);,%String1%%String2%,0,MatchA,NomA,1,Test1

But notice that I skipped the Replace String. Also if I included the Replace String like this:
RegEx>\b(\d\d?)\b(?!.*\b\1\b);,%String1%%String2%,0,MatchA,NomA,1,,Test1

It again returned the correct data.

Is the Replace String optional?
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: RegEx

Post by Marcus Tettmar » Wed May 28, 2014 6:19 pm

Replace is optional yes.


Sent from my iPad using Tapatalk
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: RegEx

Post by JRL » Thu May 29, 2014 10:29 pm

@PepsiHog
Could you post the working code?

@The World
Could this be modified to remove duplicates from a list? Below is a script that is working, but it takes a couple of seconds to remove the duplicates. I have two lists in the script. The first is a list with duplicates, The second is a list that by using Excel has had the duplicated items removed. My goal was to write a script that could produce list two from list one. As I said, the method works but is slow compared to excel which is pretty much instantaneous.

The process PepsiHog is doing seems to be close to removing duplicates. Rather than removing it is reporting. That is as close as anything else I could find searching the forum. I am dismal with regex. Anyone already have this worked out?



Code: Select all

VBSTART
VBEND

//Start timing
VBEval>timer,StartTime

//Set the two lists to variables
LabelToVar>NameList,vData
LabelToVar>DesiredList,GoodList
  //Initialize the variable for the de-duplicated list
  Let>NewList=
  //There better and more reliable methods to create an absolutely
  //unique set of characters,  but this one works with this list.
  Let>UniqPatt=##~#~^~#~##
  //Inject the unique pattern into the list so it surrounds every list member. 
  StringReplace>vData,crlf,%UniqPatt%%CRLF%%UniqPatt%,vData
  Let>vData=%crlf%%UniqPatt%%vData%
  //Parse out duplicates
  Repeat>vData
    Separate>vData,%crlf%%UniqPatt%,vLine
    Let>value=vLine_2
    StringReplace>vData,%UniqPatt%%value%%CRLF%,,vData
    StringReplace>value,UniqPatt,,value
    //Make a new list of unique values.
    Let>NewList=%NewList%%value%%crlf%
  Until>vData=%crlf%%UniqPatt%


//Display success or failure in how many seconds
VBEval>timer-%StartTime%,TotalTime
  If>NewList=GoodList
    MDL>Success in %TotalTime% seconds
  Else
    MDL>Failure in %TotalTime% seconds
  EndIf

/*
NameList:
HTML
code
tion
Window

A
AA
AAA
AAAA
AESEncrypt
Hash
SetRoundMode
ZipAddFiles
ZipExtractFiles
HTMLEncode
HTMLDecode
PopupMenu
Wow64DisableRedirection
Wow64EnableRedirection
DelVariable
DelArray
ArrayDim
DateAdd
DateDiff
DatePart
DateLocal
TimeAdd
TimeDiff
TimePart
TimeLocal

GetNewestFile
GetOldestFile
GetTextPos
FindObject
SetObjectText
ObjectSendText
ObjectSendKeys
Timer
GetWindowChildList
ColorToRGB
RegistryEnumKeys
RegistryEnumVals
GetWindowParent
XLSheetToArray
IsConnectedToInternet
ExtractFileName
ExtractFilePath
GetOldestFile
ExtractFileExt
AddTrayIcon
DelTrayIcon
AddTrayHandler
AddDialogHandler
SetDialogProperty
GetDialogProperty
PrintDialog
XLCreate
XLAddSheet
A
XLDelCol
XLDelRow
XLDelSheet
XLGetCell
XLSetCell
XLOpen
XLQuit
XLRun
XLSave
XLGetSheetDims
While
EndWhile
KillProcess
ProcessExists
WaitProcessExists
WaitProcessTerminated
ArrayCount
ArraySort
LabelToVar
IncludeFromVar
FindObject
SkipLabel
CSVFileToArray
GetFocusedObject
GetClipBoard
PutClipBoard
WaitClipBoard
Day
DayOfWeek
GetDate
GetTime
Hour
Min
Month
Sec
Year
DDEPoke
DDERequest
CloseDialog
Dialog
EndDialog
GetDialogAction
ResetDialogAction
Show
AppendFile
ChangeDirectory
CopyFile
CopyFolder
CountFiles
CreateDir
DeleteFile
DeleteFolder
EditIniFile
FileDate
FileSize
FileTime
GetFileList
IfDirExists
IfNotDirExists
IfFileChanged
IfNotFileChanged
IfFileExists
IfNotFileExists
MoveFile
RenameFile
ReadFile
ReadIniFile
ReadLn
WriteLn
FTPDelFile
FTPRemoveDir
FTPMakeDir
FTPGetDirList
FTPGetFile
FTPPutFile
FTPRenameFile
HTTPRequest
RetrievePOP3
SMTPSendMail
If
IfNot
IfWindowOpen
IfNotWindowOpen
Ascii
CapsOff
CapsOn
NumOff
NumOn
Press
Release
ScrollOff
ScrollOn
SendText
Send
WaitKeyDown
Ask
Input
Message
MessageModal
Assigned
BlockInput
DateStamp
GetCheckBox
GetControlText
GetEnvVar
GetListItem
GetPixelColor
GetRectCheckSum
GetTreeNode
LibFree
LibFunc
LibFuncW
LibLoad
PlayWav
PushButton
Random
ScreenCapture
SelectMenu
SetCheckBox
SetControlText
SetEnvVar
TimeStamp
WaitCursorChanged
WaitPixelColor
WaitRectChanged
GetCaretPos
GetCursorPos
LClick
LDblClick
LDown
LUp
MClick
MDblClick
MDown
MUp
RClick
RDblClick
RDown
RUp
MouseMove
MouseMoveRel
MouseOver
Toolbar
Add
Let
Trunc
Round
Abs
ArcTan
Cos
Exp
Frac
Int
Ln
Pi
Sin
Sqr
Sqrt
Power
Sub
RegistryDelKey
RegistryDelVal
RegistryReadKey
RegistryWriteKey
ExecuteFile
RunProgram
Run
GoSub
SRT
END
Goto
Label
Macro
OnEvent
Remark
IncludeFromVar
Repeat
Until
Wait
WaitReady
ConCat
Crypt
UpperCase
LowerCase
Trim
LTrim
RTrim
Length
MidStr
Position
Separate
StringReplace
VBEND
VBSTART
VBEval
VBRun
CloseWindow
FindWindowWithText
GetActiveWindow
GetWindowHandle
GetWindowNames
GetWindowPos
GetWindowSize
GetWindowProcess
GetWindowText
MoveWindow
ResizeWindow
SetFocus
ShutDownWindows
AAAA
WaitWindowChanged
WaitWindowClosed
WaitWindowOpen
WaitWindowFocused
WindowAction
GetScreenRes
FindImagePos
CompareBitmaps
WaitScreenImage
TelnetConnect
TelnetClose
TelnetSend
TelnetWaitFor
AA
Include
Exit
Base64
RGB
SetDialogObjectFocus
SetDialogObjectVisible
SetDialogObjectFont
SetDialogObjectColor
GetTextReset
GetTextAtPoint
GetTextInRect
GetWindowTextEx
WaitScreenText
GetWindowList
DBClose
DBConnect
DBExec
DBQuery
RegEx
SOWrite
SOWriteLn
ExportData
IEWait
AAAA
IEGetTags
IEGetTagsByAttrib
IETagEvent
IETagEventByAttrib
IEClickTag
IEContainsText
IECreate
IEQuit
IEExtractTable
IEExtractTableByName
IEExtractTag
IEExtractTagByName
IEExtractTagByAttrib
IEFormFill
IEFormSubmit
A
IEGetHWND
IEGetURL
IEGetTagPos
IEGoBack
IEGoForward
IENavigate
IEOnDownload
IERefresh
IESetTimeout
IESHowIE
IEWaitDocumentComplete
IEWaitFileDownload
IEWaitForText
IEWaitTimeout
IEWaitNew
IEGetFromURL
UIAccessibleList
UIClick
UIFocus
UIGetValue
UIPos
UISelect
UISetValue
RP_WAIT
RP_WINDOWMODE
RP_DISPLAYERROR
RP_WIN64PROCESS
WIN_USEHANDLE
WIN_REGEX
WF_TYPE
WW_TIMEOUT
WSI_TIMEOUT
WST_TIMEOUT
CF_OVERWRITE
FTP_USETLS
SSL_CERT
SSL_ROOT_CERT
SSL_KEY
HTTP_SSL
FTP_STATUS
FTP_TIMEOUT
HTTP_TIMEOUT
HTTP_REDIRECTS
POP3_STATUS
POP3_PORT
POP3_TIMEOUT
POP3_MSGSIZELIMIT
POP3_DELETE
SENDMAIL_STATUS
SMTP_CCLIST
SMTP_BCCLIST
SMTP_AUTH
SMTP_USERID
SMTP_PASSWORD
SMTP_RECEIPT
SMTP_PORT
SK_DELAY
SK_IGNORECAPS
SK_LEGACY
ASK_TIMEOUT
INPUT_TIMEOUT
INPUT_BROWSE
INPUT_PASSWORD
MSG_STAYONTOP
MSG_CENTERED
MSG_XPOS
MSG_YPOS
MSG_HEIGHT
MSG_WIDTH
REG_INTASSTR
CRYPT_LEVEL
VBS_TIMEOUT
AAA
GAW_TYPE
GFL_TYPE
MF_RENAME
WLN_NOCRLF
WFP_TIMEOUT
REG_64
FIP_SCANPIXELS
WFP_TIMEOUT
REG_64
FIP_SCANPIXELS
WFP_TIMEOUT
REG_64
FIP_SCANPIXELS
HTML
code
tion
Window
A
AA
AAA
AAAA
AESEncrypt
Hash
SetRoundMode
ZipAddFiles
ZipExtractFiles
HTMLEncode
HTMLDecode
PopupMenu
Wow64DisableRedirection
Wow64EnableRedirection
DelVariable
DelArray
ArrayDim
DateAdd
DateDiff
DatePart
DateLocal
TimeAdd
TimeDiff
TimePart
TimeLocal
GetNewestFile
GetOldestFile
GetTextPos
FindObject
SetObjectText
ObjectSendText
ObjectSendKeys
Timer
GetWindowChildList
ColorToRGB
RegistryEnumKeys
RegistryEnumVals
GetWindowParent
XLSheetToArray
IsConnectedToInternet
ExtractFileName
ExtractFilePath
GetOldestFile
ExtractFileExt
AddTrayIcon
DelTrayIcon
AddTrayHandler
AddDialogHandler
SetDialogProperty
GetDialogProperty
PrintDialog
XLCreate
XLAddSheet
A
XLDelCol
XLDelRow
XLDelSheet
XLGetCell
XLSetCell
XLOpen
XLQuit
XLRun
XLSave
XLGetSheetDims
While
EndWhile
KillProcess
ProcessExists
WaitProcessExists
WaitProcessTerminated
ArrayCount
ArraySort
LabelToVar
IncludeFromVar
FindObject
SkipLabel
CSVFileToArray
GetFocusedObject
GetClipBoard
PutClipBoard
WaitClipBoard
Day
DayOfWeek
GetDate
GetTime
Hour
Min
Month
Sec
Year
DDEPoke
DDERequest
CloseDialog
Dialog
EndDialog
GetDialogAction
ResetDialogAction
Show
AppendFile
ChangeDirectory
CopyFile
CopyFolder
CountFiles
CreateDir
DeleteFile
DeleteFolder
EditIniFile
FileDate
FileSize
FileTime
GetFileList
IfDirExists
IfNotDirExists
IfFileChanged
IfNotFileChanged
IfFileExists
IfNotFileExists
MoveFile
RenameFile
ReadFile
ReadIniFile
ReadLn
WriteLn
FTPDelFile
FTPRemoveDir
FTPMakeDir
FTPGetDirList
FTPGetFile
FTPPutFile
FTPRenameFile
HTTPRequest
RetrievePOP3
SMTPSendMail
If
IfNot
IfWindowOpen
IfNotWindowOpen
Ascii
CapsOff
CapsOn
NumOff
NumOn
Press
Release
ScrollOff
ScrollOn
SendText
Send
WaitKeyDown
Ask
Input
Message
MessageModal
Assigned
BlockInput
DateStamp
GetCheckBox
GetControlText
GetEnvVar
GetListItem
GetPixelColor
GetRectCheckSum
GetTreeNode
LibFree
LibFunc
LibFuncW
LibLoad
PlayWav
PushButton
Random
ScreenCapture
SelectMenu
SetCheckBox
SetControlText
SetEnvVar
TimeStamp
WaitCursorChanged
WaitPixelColor
WaitRectChanged
GetCaretPos
GetCursorPos
LClick
LDblClick
LDown
LUp
MClick
MDblClick
MDown
MUp
RClick
RDblClick
RDown
RUp
MouseMove
MouseMoveRel
MouseOver
Toolbar
Add
Let
Trunc
Round
Abs
ArcTan
Cos
Exp
Frac
Int
Ln
Pi
Sin
Sqr
Sqrt
Power
Sub
RegistryDelKey
RegistryDelVal
RegistryReadKey
RegistryWriteKey
ExecuteFile
RunProgram
Run
GoSub
SRT
END
Goto
Label
Macro
OnEvent
Remark
IncludeFromVar
Repeat
Until
Wait
WaitReady
ConCat
Crypt
UpperCase
LowerCase
Trim
LTrim
RTrim
Length
MidStr
Position
Separate
StringReplace
VBEND
VBSTART
VBEval
VBRun
CloseWindow
FindWindowWithText
GetActiveWindow
GetWindowHandle
GetWindowNames
GetWindowPos
GetWindowSize
GetWindowProcess
GetWindowText
MoveWindow
ResizeWindow
SetFocus
ShutDownWindows
AAAA
WaitWindowChanged
WaitWindowClosed
WaitWindowOpen
WaitWindowFocused
WindowAction
GetScreenRes
FindImagePos
CompareBitmaps
WaitScreenImage
TelnetConnect
TelnetClose
TelnetSend
TelnetWaitFor
AA
Include
Exit
Base64
RGB
SetDialogObjectFocus
SetDialogObjectVisible
SetDialogObjectFont
SetDialogObjectColor
GetTextReset
GetTextAtPoint
GetTextInRect
GetWindowTextEx
WaitScreenText
GetWindowList
DBClose
DBConnect
DBExec
DBQuery
RegEx
SOWrite
SOWriteLn
ExportData
IEWait
AAAA
IEGetTags
IEGetTagsByAttrib
IETagEvent
IETagEventByAttrib
IEClickTag
IEContainsText
IECreate
IEQuit
IEExtractTable
IEExtractTableByName
IEExtractTag
IEExtractTagByName
IEExtractTagByAttrib
IEFormFill
IEFormSubmit
A
IEGetHWND
IEGetURL
IEGetTagPos
IEGoBack
IEGoForward
IENavigate
IEOnDownload
IERefresh
IESetTimeout
IESHowIE
IEWaitDocumentComplete
IEWaitFileDownload
IEWaitForText
IEWaitTimeout
IEWaitNew
IEGetFromURL
UIAccessibleList
UIClick
UIFocus
UIGetValue
UIPos
UISelect
UISetValue
RP_WAIT
RP_WINDOWMODE
RP_DISPLAYERROR
RP_WIN64PROCESS
WIN_USEHANDLE
WIN_REGEX
WF_TYPE
WW_TIMEOUT
WSI_TIMEOUT
WST_TIMEOUT
CF_OVERWRITE
FTP_USETLS
SSL_CERT
SSL_ROOT_CERT
SSL_KEY
HTTP_SSL
FTP_STATUS
FTP_TIMEOUT
HTTP_TIMEOUT
HTTP_REDIRECTS
POP3_STATUS
POP3_PORT
POP3_TIMEOUT
POP3_MSGSIZELIMIT
POP3_DELETE
SENDMAIL_STATUS
SMTP_CCLIST
SMTP_BCCLIST
SMTP_AUTH
SMTP_USERID
SMTP_PASSWORD
SMTP_RECEIPT
SMTP_PORT
SK_DELAY
SK_IGNORECAPS
SK_LEGACY
ASK_TIMEOUT
INPUT_TIMEOUT
INPUT_BROWSE
INPUT_PASSWORD
MSG_STAYONTOP
MSG_CENTERED
MSG_XPOS
MSG_YPOS
MSG_HEIGHT
MSG_WIDTH
REG_INTASSTR
CRYPT_LEVEL
VBS_TIMEOUT
AAA
GAW_TYPE
GFL_TYPE
MF_RENAME
WLN_NOCRLF
WFP_TIMEOUT
REG_64
FIP_SCANPIXELS
WFP_TIMEOUT
REG_64
FIP_SCANPIXELS
WFP_TIMEOUT
REG_64
FIP_SCANPIXELS
*/

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////////////////////////////////// Divider ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

/*
DesiredList:
HTML
code
tion
Window

A
AA
AAA
AAAA
AESEncrypt
Hash
SetRoundMode
ZipAddFiles
ZipExtractFiles
HTMLEncode
HTMLDecode
PopupMenu
Wow64DisableRedirection
Wow64EnableRedirection
DelVariable
DelArray
ArrayDim
DateAdd
DateDiff
DatePart
DateLocal
TimeAdd
TimeDiff
TimePart
TimeLocal
GetNewestFile
GetOldestFile
GetTextPos
FindObject
SetObjectText
ObjectSendText
ObjectSendKeys
Timer
GetWindowChildList
ColorToRGB
RegistryEnumKeys
RegistryEnumVals
GetWindowParent
XLSheetToArray
IsConnectedToInternet
ExtractFileName
ExtractFilePath
ExtractFileExt
AddTrayIcon
DelTrayIcon
AddTrayHandler
AddDialogHandler
SetDialogProperty
GetDialogProperty
PrintDialog
XLCreate
XLAddSheet
XLDelCol
XLDelRow
XLDelSheet
XLGetCell
XLSetCell
XLOpen
XLQuit
XLRun
XLSave
XLGetSheetDims
While
EndWhile
KillProcess
ProcessExists
WaitProcessExists
WaitProcessTerminated
ArrayCount
ArraySort
LabelToVar
IncludeFromVar
SkipLabel
CSVFileToArray
GetFocusedObject
GetClipBoard
PutClipBoard
WaitClipBoard
Day
DayOfWeek
GetDate
GetTime
Hour
Min
Month
Sec
Year
DDEPoke
DDERequest
CloseDialog
Dialog
EndDialog
GetDialogAction
ResetDialogAction
Show
AppendFile
ChangeDirectory
CopyFile
CopyFolder
CountFiles
CreateDir
DeleteFile
DeleteFolder
EditIniFile
FileDate
FileSize
FileTime
GetFileList
IfDirExists
IfNotDirExists
IfFileChanged
IfNotFileChanged
IfFileExists
IfNotFileExists
MoveFile
RenameFile
ReadFile
ReadIniFile
ReadLn
WriteLn
FTPDelFile
FTPRemoveDir
FTPMakeDir
FTPGetDirList
FTPGetFile
FTPPutFile
FTPRenameFile
HTTPRequest
RetrievePOP3
SMTPSendMail
If
IfNot
IfWindowOpen
IfNotWindowOpen
Ascii
CapsOff
CapsOn
NumOff
NumOn
Press
Release
ScrollOff
ScrollOn
SendText
Send
WaitKeyDown
Ask
Input
Message
MessageModal
Assigned
BlockInput
DateStamp
GetCheckBox
GetControlText
GetEnvVar
GetListItem
GetPixelColor
GetRectCheckSum
GetTreeNode
LibFree
LibFunc
LibFuncW
LibLoad
PlayWav
PushButton
Random
ScreenCapture
SelectMenu
SetCheckBox
SetControlText
SetEnvVar
TimeStamp
WaitCursorChanged
WaitPixelColor
WaitRectChanged
GetCaretPos
GetCursorPos
LClick
LDblClick
LDown
LUp
MClick
MDblClick
MDown
MUp
RClick
RDblClick
RDown
RUp
MouseMove
MouseMoveRel
MouseOver
Toolbar
Add
Let
Trunc
Round
Abs
ArcTan
Cos
Exp
Frac
Int
Ln
Pi
Sin
Sqr
Sqrt
Power
Sub
RegistryDelKey
RegistryDelVal
RegistryReadKey
RegistryWriteKey
ExecuteFile
RunProgram
Run
GoSub
SRT
END
Goto
Label
Macro
OnEvent
Remark
Repeat
Until
Wait
WaitReady
ConCat
Crypt
UpperCase
LowerCase
Trim
LTrim
RTrim
Length
MidStr
Position
Separate
StringReplace
VBEND
VBSTART
VBEval
VBRun
CloseWindow
FindWindowWithText
GetActiveWindow
GetWindowHandle
GetWindowNames
GetWindowPos
GetWindowSize
GetWindowProcess
GetWindowText
MoveWindow
ResizeWindow
SetFocus
ShutDownWindows
WaitWindowChanged
WaitWindowClosed
WaitWindowOpen
WaitWindowFocused
WindowAction
GetScreenRes
FindImagePos
CompareBitmaps
WaitScreenImage
TelnetConnect
TelnetClose
TelnetSend
TelnetWaitFor
Include
Exit
Base64
RGB
SetDialogObjectFocus
SetDialogObjectVisible
SetDialogObjectFont
SetDialogObjectColor
GetTextReset
GetTextAtPoint
GetTextInRect
GetWindowTextEx
WaitScreenText
GetWindowList
DBClose
DBConnect
DBExec
DBQuery
RegEx
SOWrite
SOWriteLn
ExportData
IEWait
IEGetTags
IEGetTagsByAttrib
IETagEvent
IETagEventByAttrib
IEClickTag
IEContainsText
IECreate
IEQuit
IEExtractTable
IEExtractTableByName
IEExtractTag
IEExtractTagByName
IEExtractTagByAttrib
IEFormFill
IEFormSubmit
IEGetHWND
IEGetURL
IEGetTagPos
IEGoBack
IEGoForward
IENavigate
IEOnDownload
IERefresh
IESetTimeout
IESHowIE
IEWaitDocumentComplete
IEWaitFileDownload
IEWaitForText
IEWaitTimeout
IEWaitNew
IEGetFromURL
UIAccessibleList
UIClick
UIFocus
UIGetValue
UIPos
UISelect
UISetValue
RP_WAIT
RP_WINDOWMODE
RP_DISPLAYERROR
RP_WIN64PROCESS
WIN_USEHANDLE
WIN_REGEX
WF_TYPE
WW_TIMEOUT
WSI_TIMEOUT
WST_TIMEOUT
CF_OVERWRITE
FTP_USETLS
SSL_CERT
SSL_ROOT_CERT
SSL_KEY
HTTP_SSL
FTP_STATUS
FTP_TIMEOUT
HTTP_TIMEOUT
HTTP_REDIRECTS
POP3_STATUS
POP3_PORT
POP3_TIMEOUT
POP3_MSGSIZELIMIT
POP3_DELETE
SENDMAIL_STATUS
SMTP_CCLIST
SMTP_BCCLIST
SMTP_AUTH
SMTP_USERID
SMTP_PASSWORD
SMTP_RECEIPT
SMTP_PORT
SK_DELAY
SK_IGNORECAPS
SK_LEGACY
ASK_TIMEOUT
INPUT_TIMEOUT
INPUT_BROWSE
INPUT_PASSWORD
MSG_STAYONTOP
MSG_CENTERED
MSG_XPOS
MSG_YPOS
MSG_HEIGHT
MSG_WIDTH
REG_INTASSTR
CRYPT_LEVEL
VBS_TIMEOUT
GAW_TYPE
GFL_TYPE
MF_RENAME
WLN_NOCRLF
WFP_TIMEOUT
REG_64
FIP_SCANPIXELS
*/

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: RegEx

Post by PepsiHog » Mon Jun 02, 2014 11:57 pm

@JRL

Hello again. Long time me been away, good to see someone I am familiar with. I'm still working out RegEx too. Which is why I didn't post what I have. But here is a quick learner. Hope it helps.

Oops. Could you be more specific about what you need to remove? The pattern in this RegEx is for digits.(\d)

RegEx>(\d)(?=.*\b\1\b),Text,0,match,nom,0

The key is the lookahead = (?=.*\b\1\b) This tells RegEx to look ahead for the same result as it got in the first group.(\d)

So if the number was 9, it looks for another 9 in your text. Everything that you want to refer back to needs to be between parentheses. In the LookAhead the \1 refers to the first set of parentheses. (Sorry I can't think what they are called so I'm calling them groups.)

You can have as many groups as you need. To use the result of a group refer to like $1 = is the first group.

RegEx>(\d)(?=.*\b\1\b),Text,0,match,nom,1,$1,Result

Or ofcourse you can use the array match_1......and so on.

The other one is called a Negative LookAhead. Basically, look for what you don't want.

RegEx>(\d)(?!.*\b\1\b),Text,0,match,nom,1,$1,Result

Since RegEx consumes the results, using negative lookahead leaves your result being ONLY what you want.(or don't want.)

If you have multiple groups that you want considered as one, then enclose them all in parentheses.

RegEx>((\d);(\d);(\b)).......

Ofcourse this is simplistic. The first group is the whole thing. The next group is the first parentheses set. And the third is the next set. And so on.

In the result they are refered to as $1 $2 $3..........

If you post something more specific maybe I can help you further. If you need it. I will try to check back tomorrow.

PepsiHog
Good Luck.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: RegEx

Post by PepsiHog » Tue Jun 03, 2014 12:03 am

Also, you can use question mark to make part or all of a group optional.

RegEx>(\d\d?)....

This says look for one or two digits. The second digit is optional due to the question mark. You can make the whole group optional by following it with a question mark. (\d\d?)?

PepsiHog

Oh yeah. The \b is a word boundary. The beginning of a string matches this. A word is [a-z A-Z 0-9]. It also matches a backspace. The boundary is anything that is not a word.

Tip: I combine my strings within RegEx. Saves a line of code.

RegEx>pattern,%String1%%String2%,0,............

You can place a delimiter between them if needed. %String1%;%String2%

I have posted other so-called learners, which are likely buried, but you could search my posts. They may be helpful.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: RegEx

Post by PepsiHog » Tue Jun 03, 2014 12:36 am

OK, I had a senior moment. I didn't scroll down on your code. Sorry. I'm looking at it.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: RegEx

Post by JRL » Tue Jun 03, 2014 4:38 am

Thanks PH. I'll take a look at it in the morning and see if I can make something work.

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: RegEx

Post by PepsiHog » Sun Jun 08, 2014 1:57 pm

@JRL

I played around with it for a while. But I didn't really get any where with it. I can't right now, but later I'll post what I was trying. Not to volunteer anyone, but I bet someone by the name of Marcus could scratch out this RegEx easy.

PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts