Jump to content

Help with RegExp


gosu
 Share

Recommended Posts

$line = "Posteingang für <b>hans@test.de</b> (7):"
if RegExp($line, "<b>hans@test.de</b> \(\d):", "Test") Then
    MsgBox(0, "", UBound($Test))
Else
    MsgBox(0, "", "ERROR!")
EndIf

$Test is always empty. It matches, but how can I get the value in the brackets?

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Link to comment
Share on other sites

~

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Link to comment
Share on other sites

$line = "Posteingang für <b>hans@test.de</b> (7):"
if RegExp($line, "<b>hans@test.de</b> \(\d):", "Test") Then
    MsgBox(0, "", UBound($Test))
Else
    MsgBox(0, "", "ERROR!")
EndIf

$Test is always empty. It matches, but how can I get the value in the brackets?

<{POST_SNAPBACK}>

I haven't looked into the RegEx stuff yet, but working from my past RegEx experience, I think the problem is with the \ in front of your (. This is telling the function to evaluate it as an actual bracket character, instead of the RegEx command. I think what you want, although I'm guessing here, is something like this:

RegExp($line, "<b>hans@test.de</b> \((\d)\):", "Test")

This checks for actual bracket characters around a digit character (assuming \d stands for digit). Thus, this will harvest the 7 out of the brackets, leaving you with just the number.

*Edit: Added BBCode tags

Edited by Saunders
Link to comment
Share on other sites

I haven't looked into the RegEx stuff yet, but working from my past RegEx experience, I think the problem is with the \ in front of your (. This is telling the function to evaluate it as an actual bracket character, instead of the RegEx command. I think what you want, although I'm guessing here, is something like this:

RegExp($line, "<b>hans@test.de</b> \((\d)\):", "Test")

This checks for actual bracket characters around a digit character (assuming \d stands for digit). Thus, this will harvest the 7 out of the brackets, leaving you with just the number.

*Edit: Added BBCode tags

<{POST_SNAPBACK}>

Thank you very much! I´m new to RegEx. I´ll give you credit in this script when it´s done :idiot:

[quote name='d2hacker88' date='Jan 6 2005, 05:10 PM']Can someone please help me out with autoit like gimme a link on how to use it cause i have no experience with computer languages and i'd like to make a program with autoit in order to empress my computer teacher.[right][snapback]52215[/snapback][/right][/quote]

Link to comment
Share on other sites

$line = "Posteingang für <b>hans@test.de</b> (7):"
if RegExp($line, "<b>hans@test.de</b> \(\d):", "Test") Then
    MsgBox(0, "", UBound($Test))
Else
    MsgBox(0, "", "ERROR!")
EndIf

$Test is always empty. It matches, but how can I get the value in the brackets?

<{POST_SNAPBACK}>

The problem is mixing actual parentheses and the grouping parentheses.

if RegExp($line, "<b>hans@test.de</b> \((\d+)\):", "Test") Then

The number (as a string) will be stored in $Test[0].

I am currently rewriting the RegExp so that the line would be changed to:

$Test = RegExp($line, "<b>hans@test.de</b> \((\d+)\):")
If @Error = 0 Then

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

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