regex for.. well, anything?

1 view
Skip to first unread message

SpaceMarine

unread,
Nov 4, 2009, 1:54:34 PM11/4/09
to Regex
hello,

im a seasoned programmer but a regex newb. ive read some excellent
tutorials over the years, but i still often find myself starting all
over with baby steps when it comes to regexes. dunno why.

i need to plug in a regex into a software tool that validates a
string. for this particular string, i dont care *what* the value is,
just that it has one. what is the best way to write this supremely
easy requirement?


thanks,
sm

Eugeny Sattler

unread,
Nov 5, 2009, 2:39:59 AM11/5/09
to re...@googlegroups.com
Fist of all i think it is easier to check without regexes using
built-in functions like IsEmpty() function or logical "is Not NULL"
check
Calling for regex library will take additional time.

As for regex approach:
1) I think a presence of non-space character is a sign that the field
contains a value.
So the regex would be simple:

\S

2) If you are happy with just spaces or tabs or any other invisible
characters, as well .....
In this case the regex would be just the all-capturing dot:
.

Can you see it well above ? :)

Lack of boundaries \b and anchors (^, $, \A, \Z) ensures that this
regex allows this any symbol to be located in any place of a target
string (in the beginning, at the end, in the middle)

SpaceMarine

unread,
Nov 5, 2009, 4:19:01 PM11/5/09
to Regex
> Fist of all i think it is easier to check without regexes using
> built-in functions

impossible in this scenario. thus my post :)

\S sounds like the winner.


thanks!
sm


On Nov 5, 1:39 am, Eugeny Sattler <eugeny.satt...@gmail.com> wrote:
> Fist of all i think it is easier to check without regexes using
> built-in functions like  IsEmpty() function or  logical "is Not NULL"
> check
> Calling for regex library will take additional time.
>
> As for regex approach:
> 1) I think a presence of non-space character is a sign that the field
> contains a value.
> So the regex would be simple:
>
> \S
>
> 2) If you are happy with just spaces or tabs or any other invisible
> characters, as well .....
> In this case the regex would be just the all-capturing dot:
> .
>
> Can you see it well above ? :)
>
> Lack of boundaries \b and anchors (^, $, \A, \Z) ensures that this
> regex allows this any symbol to be located in any place of a target
> string (in the beginning, at the end, in the middle)
>

SpaceMarine

unread,
Nov 20, 2009, 4:35:04 PM11/20/09
to Regex
update on this...

i'm using HP's Quick Test Pro, an enterprise scripting tool designed
to record and verify front-end application use (regression testing).
in it, designating a GUI textbox with the \S pattern (meaning, the
textbox may contain anything) does not work; tests don't pass.

however, using .* as the pattern does work.


sm

eugeny....@gmail.com

unread,
Nov 21, 2009, 5:31:53 AM11/21/09
to Regex
> the \S pattern (meaning, the
> textbox may contain anything) does not work; tests don't pass.
>
> however, using .* as the pattern does work.

I think it is because of the following.
If the software requires "the whole string should be matched",
indeed .* is the right thing to use.

if the software applies "find a substring is enough"
approach , then \S should suffice.
\S might be not supported - in this case [^\s] which is the same, can
be used.
Reply all
Reply to author
Forward
0 new messages