Sign in to follow this  
Followers 0
nitekram

stringregexp help - not even sure it will work?

4 posts in this topic

#1 ·  Posted (edited)

I am new to this function and have never used it before, so forgive me if I do not give example code...I am not even sure it will be able to do what I want.

I have two strings - nothing in either string will be the same from search to search. With either the first string or the second. And this is only a small example of what I might be searching for. I am not even sure which way to search - just that I want to be able to find these strings and compare them for key terms, IP address, DNS names, ect.

Is this even possible?

First Set of strings:

$string1a = IF-az201wlnrtr801o19d1/437309440 [Ethernet3/14] [169.254.9.17] [az201wlnswt801k23a1_te6/1]

$string2a = MEM-CISCO_NXOS-nmcvnimhubsmdsnat01->cisco_nxos10.10.16.13MDS.Memory.Utilization

$string3a = zuk68voipcic002.re.stuff.com

$string4a = 10.208.50.30/Gateway/10.212.12.15060transporttcp

$string5a = PORT-dspmis-s-core-01/2.6 [Gi2/0/6] [to DSPMIS-S-LSHOP-01 G 1/1/2]

Second Set of strings:

$string1b = az201wlnrtr801o19d1, az202wlnrtr803o19d1, az203wlnrtr805o19d1

$string2b = 10.10.16.13 10.10.16.14 10.10.16.15

$string3b = zuk68voipcic002 and zuk68voipcic003

$string4b = 10.208.50.30

$string5b = dspmis-s-core/dspmis-r-core/dspmis-w-core

This is what I am using right now - where $sNameColumn is coming from First Set of Strings above, and $aArrayExcel[$y][21] is the Second Set of Strings....I do this about 7 times changing out the delimiter in stringsplit from: comma, space, open bracket, dash, period, forward slash, backward slash.

$aCheckComma = StringSplit($aAlert[$sNameColumn], ',')
_ArrayDelete($aCheckComma, 0)
For $x = 0 To UBound($aCheckComma) - 1
    For $y = 2 To UBound($aArrayExcel) - 2
        $CheckStartDate = $aArrayExcel[$y][3] ; start date
        $CheckEndDate = $aArrayExcel[$y][5] ; end date
        If StringInStr($aArrayExcel[$y][21], $aCheckComma[$x]) And CheckTodaysDate($CheckStartDate, $CheckEndDate, $TodaysDate) _
                And $CheckCustomerName[$iFoundIndex][1] = $aArrayExcel[$y][1] Then
            ConsoleWrite(@CRLF)
            ConsoleWrite('+> FOUND -->> ( , ) ' & $aCheckComma[$x] & ' in ' & $aArrayExcel[$y][21])
            ConsoleWrite(@CRLF)
            $GCARnumber = $aArrayExcel[$y][2]
            $FoundGCAR = True
            ExitLoop 2
            ;MsgBox('', 'found in gcar', 'found;')
        Else
            ;#cs
            ConsoleWrite('Not Found in excel array ( , ) ' & $aCheckComma[$x] _
                     & @CRLF & $aArrayExcel[$y][21] & @CRLF & @CRLF)
            ;MsgBox('', 'name not found in gcar', 'not found')
            ;#ce
        EndIf

    Next
Next

EDIT used tidy on code

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites



I would recommend looking at StringRegExp with the last param being 1 as a start seeing as you probably are going to want an array of the strings that match what your looking for, this makes handling them easier.

The following functions would be the ones that I would use in such a function.

StringRegExp

$sNewString = StringRegExpReplace("something/digit3.anything", "(/)|(d)|(.)|()", "") ; or instead "[/d.]" should work.

Where "" the backward slash escapes illegal regex characters, "d" matches any digit, so this would remove the period, slashes, digits and thats it but you get the idea bro.

StringMid - maybe so check it out.

Make an attempt to use the RegEx and I'm sure if I don't revisit your topic another user will that probably has a lot more experience with them than I do.


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

There are three functions in the Wiki to check and validate IP addresses. There are other usefull functions as well, just browse around. They'll give you an idea on how to write up your own check functions.


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This is what I came up with: still testing to see if this is any better. I am taking out all characters except for alpha numeric and then splitting the second string into an array based on the type of delimiter in the string. Still not sure if this will work, and it is very hard to test, as I stated there are some real unique strings that I am dealing with - the human eye can spot it in about a second, but that second grows when there are over 800 line items to search through.

Thanks for the help I have receive so far - anyone else have any ideas?

$sCheckNewString &= StringRegExpReplace($aAlert[$sNameColumn], "(/)|(.)|()|(-)|([)|(])|( )|(_)", "") ; or instead "[/d.]"

For $y = 2 To UBound($aArrayExcel) - 2

If StringInStr($aArrayExcel[$y][21], ',') Then
$Delimiter = ','
ElseIf StringInStr($aArrayExcel[$y][21], ' ') Then
$Delimiter = ' '
ElseIf StringInStr($aArrayExcel[$y][21], '/') Then
$Delimiter = '/'
ElseIf StringInStr($aArrayExcel[$y][21], 'and') Then
$Delimiter = 'and'
EndIf

If $Delimiter = 'and' Then
$aCheckString = StringSplit($aArrayExcel[$y][21], $Delimiter, 1)
Else
$aCheckString = StringSplit($aArrayExcel[$y][21], $Delimiter)
EndIf

$CheckStartDate = $aArrayExcel[$y][3] ; start date
$CheckEndDate = $aArrayExcel[$y][5] ; end date

For $z = 1 To UBound($aCheckString) - 1
If StringInStr($sCheckNewString, $aCheckString[$z]) And CheckTodaysDate($CheckStartDate, $CheckEndDate, $TodaysDate) _
And $CheckCustomerName[$iFoundIndex][1] = $aArrayExcel[$y][1] Then
$GCARnumber = $aArrayExcel[$y][2]
ConsoleWrite('Found GCAR that $sCheckNewString = ' & $sCheckNewString & @CRLF & $aCheckString[$z] & @CRLF & @CRLF)
If MsgBox(4, 'GCAR FOUND', 'Please Look up GCARS# ' & $GCARnumber & @CRLF & 'For your convience it has been added to clip board!' _
& @CRLF & @CRLF & 'This is for account ' & $aAlert[$sCustomerColumn] & ' do you want to use it?') = 6 Then
ClipPut($GCARnumber)
Return
EndIf

ExitLoop 2
Else
ConsoleWrite('not found -->> ' & $sCheckNewString & ' <<-- ' & $aCheckString[$z] & @CRLF)
EndIf
Next
Next

edit - went to edit the code and now the spacing is off - sorry, I even used tidy to start - cannot fix

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
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
Sign in to follow this  
Followers 0