Jump to content

Another question about StringRegExp


Recommended Posts

I feel bad about posting another question about StringRegExp but I just spent three hours going through the old questions people posted and I couldn't find anything to address my problem. All I want to do is find AIM names in a text file. So StringRegExp should look for the pattern AIM and then also return the name that follows. After searching the forum I know that my test pattern should look something like this(^AIM/w[a-z][A-Z][1-9]) since the pattern starts with AIM and then there is some white space and then the name can consist of upper and lower case letters and numbers. If someone could help with the pattern that I am using to find AIM names I would be grateful for the help.

Link to comment
Share on other sites

Big Daddy the Code works great, thanks alot. Are you familar with the RegExp function in general from other programming languages or is there a tutorial on StringRegExp on here I am missing. I looked at the help file for the function but it doesn't say anything about /s or A+.

Link to comment
Share on other sites

  • Moderators

Big Daddy the Code works great, thanks alot. Are you familar with the RegExp function in general from other programming languages or is there a tutorial on StringRegExp on here I am missing. I looked at the help file for the function but it doesn't say anything about /s or A+.

Its there in my help file. Try looking under "StringRegExp", it has a large table with all the info. However if you look at "String Regular expression", at the bottom of the page there is a nice tool for testing patterns.
Link to comment
Share on other sites

When I go to beta\examples\helpfile and click on stringregexp all I see is this.

Local $sPattern, $sTest, $vResult, $nFlag

$sPattern = InputBox("StringRegExp Sample", "What is the pattern to test?")

$sTest = InputBox("StringRegExp Sample", "What is the line to test?")

$vResult = StringRegExp($sTest, $sPattern)

Select

Case @Error = 2

; Error. The pattern was invalid. $vResult = position in $sPattern where error occurred.

Case @Error = 0

if @Extended Then

; Success. Pattern matched. $vResult matches @Extended

Else

; Failure. Pattern not matched. $vResult = ""

EndIf

EndSelect

$sPattern = InputBox("StringRegExp Sample", "What is the pattern to test?")

$sTest = InputBox("StringRegExp Sample", "What is the line to test?")

$nFlag = InputBox("StringRegExp Sample", "What flag to use? 0 - true/false, 1 - single pattern array return, 3 - global pattern array return")

$vResult = StringRegExp($sTest, $sPattern, $nFlag)

Select

Case @Error = 1

; Error. Flag is bad. $vResult = ""

Case @Error = 2

; Error. The pattern was invalid. $vResult = position in $sPattern where error occurred.

Case @Error = 0

if @Extended Then

; Success. Pattern matched. $vResult has the text from the groups or true (1), depending on flag.

Else

; Failure. Pattern not matched. $vResult = "" or false (0), depending on flag.

EndIf

EndSelect

Am I looking at the wrong helpfile?

Link to comment
Share on other sites

  • Moderators

Use code tags when showing code please...

Type this in the Beta help file:

String Regular expression

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.

Link to comment
Share on other sites

  • Moderators

When I go to beta\examples\helpfile and click on stringregexp all I see is this.

Am I looking at the wrong helpfile?

That is not the help file, its just the example script for StringRegExp.

Try looking here: \beta\AutoIt3.chm, that is the help file.

Link to comment
Share on other sites

Thanks for showing me where the helpfile is.You can understand my confusion because the example scripts are in a folder called helpfile. After reading the helpfile I understand why you used /s and A+, but why did you put the A+ in its own set of parentheses. Thanks for your help.

Link to comment
Share on other sites

  • Moderators

Thanks for showing me where the helpfile is.You can understand my confusion because the example scripts are in a folder called helpfile. After reading the helpfile I understand why you used /s and A+, but why did you put the A+ in its own set of parentheses. Thanks for your help.

If you don't then each letter would be split into a different element of the array.
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...