Followers 0

9 posts in this topic

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.

Share on other sites

Try this:

(?:AIM\s+)(\A+)

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

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

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.

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?

Share on other sites

Use code tags when showing code please...

Type this in the Beta help file:

String Regular expression

[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 on other sites

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.

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.

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.

If you don't then each letter would be split into a different element of the array.