AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Resolved][RegEx] A void string

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
DranDane



Joined: 26 Jun 2007
Posts: 54

PostPosted: Mon Feb 25, 2008 1:25 am    Post subject: [Resolved][RegEx] A void string Reply with quote

Hi,

I hope than someone can help me here for this simple RegEx. I'm able to write more complex RegEx but not this simple case.

How can I evaluate that my string is void or only filled with blanks?


Last edited by DranDane on Mon Feb 25, 2008 11:01 am; edited 1 time in total
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Mon Feb 25, 2008 3:04 am    Post subject: Reply with quote

RegEx: Quick Reference wrote:
* An asterisk matches zero or more of the preceding character, set, or subpattern. For example, a* matches ab and aaab. It also matches at the very beginning of any string that contains no "a" at all.
...
\s Matches any single whitespace character, mainly space, tab, and newline (`r and `n). Conversely, capital \S means "any non-whitespace character".
...
Circumflex (^) and dollar sign ($) are called anchors because they don't consume any characters; instead, they tie the pattern to the beginning or end of the string being searched.

^ may appear at the beginning of a pattern to require the match to occur at the very beginning of a line. For example, ^abc matches abc123 but not 123abc.

$ may appear at the end of a pattern to require the match to occur at the very end of a line. For example, abc$ matches 123abc but not abc123.

The two anchors may be combined. For example, ^abc$ matches only abc (i.e. there must be no other characters before or after it).

Code:
var1 := "    "
var2 := "   .   "
Loop 2
{
    if RegExMatch(var%A_Index%, "^\s*$")
        MsgBox regex: var%A_Index% is blank.
    else
        MsgBox regex: var%A_Index% is not blank.

    if var%A_Index% is space
        MsgBox ifis: var%A_Index% is blank.
    else
        MsgBox ifis: var%A_Index% is not blank.
}
Back to top
View user's profile Send private message
DranDane



Joined: 26 Jun 2007
Posts: 54

PostPosted: Mon Feb 25, 2008 11:01 am    Post subject: Reply with quote

Thank you for your good example Lexikos.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group