Sign in to follow this  
Followers 0
Noobster24

Becoming crazy about StringRegExp

8 posts in this topic

Hi,

i want to check if this sentence is in a txt-file.

Sentence:

<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>

I exspected this code to work, but it doesn't :S

$file = FileOpen('C:\Documents and Settings\Beheerder\Bureaublad\Andreas\Custom \~ OSS ~\office 2003.txt',0)

$test = StringRegExp ($file, '(.*)<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>(.*)',0)

If $test = 1 Then

MsgBox(0,"ja","ja")

Else

MsgBox(0,"Nee","nee")

EndIf

What's wrong with my pattern?

greetings,

Andreas


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites



Hi,

i want to check if this sentence is in a txt-file.

Sentence:

I exspected this code to work, but it doesn't :S

What's wrong with my pattern?

greetings,

Andreas

do you just want: Result more than 50 records. Please, specify parameters of search. or all of it: <CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

do you just want: Result more than 50 records. Please, specify parameters of search. or all of it: <CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>?

The whole sentence, so:

<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>

The source of a website is written into a txt-file, i want to check if this sentence is in the txt-file...


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

.* means IIRC one or more .

try it without those (.*)'s

Okay, i'll try...

edit: Nope, doesn't work..

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Okay, i'll try...

edit: Nope, doesn't work..

Here try this:
$file = @DesktopDir & '\sre_test.txt'
$FindThis = '<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>'
If _SRE_Find($file, $FindThis) Then
    MsgBox(0, 'Info:', 'Found')
EndIf


Func _SRE_Find($s_FilePath, $s_Find)
    $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath))
    $vFound = StringRegExp($h_FRead, '(?:' & $s_Find & ')')
    If $vFound Then Return $vFound
    Return 0
EndFunc

Edit:

Obviously you want to change the $File (location/name)

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Here try this:

$file = @DesktopDir & '\sre_test.txt'
$FindThis = '<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>'
If _SRE_Find($file, $FindThis) Then
    MsgBox(0, 'Info:', 'Found')
EndIf
Func _SRE_Find($s_FilePath, $s_Find)
    $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath))
    $a_Array = StringRegExp($h_FRead, '(?:' & $s_Find & ')')
    If $a_Array Then Return $a_Array
    Return 0
EndFunc
I'll test it right now, i just want a 1 (true) returns if the sentence is found in the file or a 0 (false) if the sentence isn't found, not the place of the sentence.

i'll keep you informed...

Edit: It works, thank you! :D

Edited by Noobster24

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

Share this post


Link to post
Share on other sites

Here try this:

$file = @DesktopDir & '\sre_test.txt'
$FindThis = '<CENTER><BR>Result more than 50 records. Please, specify parameters of search.</CENTER><BR><BR>'
If _SRE_Find($file, $FindThis) Then
    MsgBox(0, 'Info:', 'Found')
EndIf
Func _SRE_Find($s_FilePath, $s_Find)
    $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath))
    $vFound = StringRegExp($h_FRead, '(?:' & $s_Find & ')')
    If $vFound Then Return $vFound
    Return 0
EndFunc

Edit:

Obviously you want to change the $File (location/name)

Yeah, i know i must change the $File :D


Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.

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