Jump to content

Help about StringRegExp


Recommended Posts

I have a paragraph :

Now.ini c361e1ef4a8461a80d97b9594f82725a      57ee1cfe85789a1d7630673c77b2501e3ace6519
Back.txt     b7a2cf799c19cc5e664c6994bb65a517    ad83558139515700f9506d6c9f75391ff50c4813

Now! I found md5 string 'c361e1ef4a8461a80d97b9594f82725a', how i get the file name before?

Note : File name, md5 and sha-1 seperated with Char(9) (tab)

Thank!!

Edited by logmein
Link to comment
Share on other sites

hi,

$string="Now.ini    c361e1ef4a8461a80d97b9594f82725a    57ee1cfe85789a1d7630673c77b2501e3ace6519"
$String_split=StringSplit($string,Chr(9),1)
$name=$String_split[1]
MsgBox(0, '', $name)

;or

$string_regEx=StringRegExp($string,"\b(.+?)\x09",3)
$name=$string_regEx[0]
MsgBox(0, '', $name)
Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

anyway I made 2 patterns for you:

#include <Array.au3>
$sString = 'Now.ini c361e1ef4a8461a80d97b9594f82725a       57ee1cfe85789a1d7630673c77b2501e3ace6519' & @CRLF & _
                'Back.txt     b7a2cf799c19cc5e664c6994bb65a517    ad83558139515700f9506d6c9f75391ff50c4813'

$aPattern1 = '(\b\w+\.\w+)(?:\s+)(\b\w+\b)'
$aPattern2 = '(\b\w+\.\w+\b\s*\b\w+\b)'
$aRegExp = StringRegExp($sString, $aPattern2, 3)
_ArrayDisplay($aRegExp)
Link to comment
Share on other sites

Thanks about the help, but I had generated the MD5 Hash : 'c361e1ef4a8461a80d97b9594f82725a' and i want to know the file name!

Link to comment
Share on other sites

well to learn try here its great for the job http://www.regular-expressions.info/tutorial.html

and you need to show us what you want if you want us to solve it as we have already done as best we can with what you have said so far.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

Well, the MD5 is 32 characters long and the SHA is 40 characters long, right?

#include <Array.au3>

Global $sPattern, $sStr
Global $aMatch

$sStr = 'Now.ini' & @TAB & 'c361e1ef4a8461a80d97b9594f82725a' & @TAB & '57ee1cfe85789a1d7630673c77b2501e3ace6519' & @CRLF & _
        'Back.txt' & @TAB & 'b7a2cf799c19cc5e664c6994bb65a517' & @TAB & 'ad83558139515700f9506d6c9f75391ff50c4813' & @CRLF

$sPattern = '(?i)(\b\w+?\.\w+)\t\w{32}\t\w{40}'
$aMatch = StringRegExp($sStr, $sPattern, 3)
If IsArray($aMatch) Then _ArrayDisplay($aMatch)
Link to comment
Share on other sites

it really dont matter how long the string is if your just looking for the "tabs" as the break point, or even just looking for \w or . characters as below :-

(?:\.|\w)+

#include <Array.au3>
$sStr = 'Now.ini' & @TAB & 'c361e1ef4a8461a80d97b9594f82725a' & @TAB & '57ee1cfe85789a1d7630673c77b2501e3ace6519' & @CRLF & _
        'Back.txt' & @TAB & 'b7a2cf799c19cc5e664c6994bb65a517' & @TAB & 'ad83558139515700f9506d6c9f75391ff50c4813' & @CRLF
$sPattern = '(?:\.|\w)+'
$aMatch = StringRegExp($sStr, $sPattern, 3)
If IsArray($aMatch) Then _ArrayDisplay($aMatch)
MsgBox(0, '', $aMatch[0])
MsgBox(0, '', $aMatch[3])
Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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