DranDane
Joined: 26 Jun 2007 Posts: 54
|
Posted: Mon Feb 25, 2008 1:25 am Post subject: [Resolved][RegEx] A void string |
|
|
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 |
|
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Mon Feb 25, 2008 3:04 am Post subject: |
|
|
| 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.
} |
|
|